Completed
Branch FET-7988-evertec-needs (20e248)
by
unknown
114:06 queued 104:38
created
core/db_classes/EE_Datetime_Ticket.class.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 	 * @param null  $timezone
32 32
 	 * @return EE_Datetime_Ticket|mixed
33 33
 	 */
34
-	public static function new_instance( $props_n_values = array(), $timezone = NULL ) {
35
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
36
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
34
+	public static function new_instance($props_n_values = array(), $timezone = NULL) {
35
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
36
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
37 37
 	}
38 38
 
39 39
 
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @param null  $timezone
44 44
 	 * @return EE_Datetime_Ticket
45 45
 	 */
46
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = NULL ) {
47
-		return new self( $props_n_values, TRUE, $timezone );
46
+	public static function new_instance_from_db($props_n_values = array(), $timezone = NULL) {
47
+		return new self($props_n_values, TRUE, $timezone);
48 48
 	}
49 49
 } //end EE_Datetime_Ticket class
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
core/db_classes/EE_Line_Item.class.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -861,7 +861,7 @@
 block discarded – undo
861 861
 
862 862
 				if ( $child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
863 863
 					$total += $child_line_item->total();
864
-				}elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){
864
+				} elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){
865 865
 					$total += $child_line_item->taxable_total();
866 866
 				}
867 867
 			}
Please login to merge, or discard this patch.
Doc Comments   +24 added lines, -25 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
 	/**
78 78
 	 * Gets TXN_ID
79
-	 * @return int
79
+	 * @return boolean
80 80
 	 */
81 81
 	function TXN_ID() {
82 82
 		return $this->get( 'TXN_ID' );
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	/**
88 88
 	 * Sets TXN_ID
89 89
 	 * @param int $TXN_ID
90
-	 * @return boolean
90
+	 * @return boolean|null
91 91
 	 */
92 92
 	function set_TXN_ID( $TXN_ID ) {
93 93
 		$this->set( 'TXN_ID', $TXN_ID );
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 	/**
113 113
 	 * Sets name
114 114
 	 * @param string $name
115
-	 * @return boolean
115
+	 * @return boolean|null
116 116
 	 */
117 117
 	function set_name( $name ) {
118 118
 		$this->set( 'LIN_name', $name );
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 
123 123
 	/**
124 124
 	 * Gets desc
125
-	 * @return string
125
+	 * @return boolean
126 126
 	 */
127 127
 	function desc() {
128 128
 		return $this->get( 'LIN_desc' );
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	/**
134 134
 	 * Sets desc
135 135
 	 * @param string $desc
136
-	 * @return boolean
136
+	 * @return boolean|null
137 137
 	 */
138 138
 	function set_desc( $desc ) {
139 139
 		$this->set( 'LIN_desc', $desc );
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 
144 144
 	/**
145 145
 	 * Gets quantity
146
-	 * @return int
146
+	 * @return boolean
147 147
 	 */
148 148
 	function quantity() {
149 149
 		return $this->get( 'LIN_quantity' );
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	/**
155 155
 	 * Sets quantity
156 156
 	 * @param int $quantity
157
-	 * @return boolean
157
+	 * @return boolean|null
158 158
 	 */
159 159
 	function set_quantity( $quantity ) {
160 160
 		$this->set( 'LIN_quantity', $quantity );
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 	/**
166 166
 	 * Gets item_id
167
-	 * @return string
167
+	 * @return boolean
168 168
 	 */
169 169
 	function OBJ_ID() {
170 170
 		return $this->get( 'OBJ_ID' );
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	/**
176 176
 	 * Sets item_id
177 177
 	 * @param string $item_id
178
-	 * @return boolean
178
+	 * @return boolean|null
179 179
 	 */
180 180
 	function set_OBJ_ID( $item_id ) {
181 181
 		$this->set( 'OBJ_ID', $item_id );
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
 	/**
187 187
 	 * Gets item_type
188
-	 * @return string
188
+	 * @return boolean
189 189
 	 */
190 190
 	function OBJ_type() {
191 191
 		return $this->get( 'OBJ_type' );
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 	/**
197 197
 	 * Sets item_type
198 198
 	 * @param string $OBJ_type
199
-	 * @return boolean
199
+	 * @return boolean|null
200 200
 	 */
201 201
 	function set_OBJ_type( $OBJ_type ) {
202 202
 		$this->set( 'OBJ_type', $OBJ_type );
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
 	/**
208 208
 	 * Gets unit_price
209
-	 * @return float
209
+	 * @return boolean
210 210
 	 */
211 211
 	function unit_price() {
212 212
 		return $this->get( 'LIN_unit_price' );
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	/**
218 218
 	 * Sets unit_price
219 219
 	 * @param float $unit_price
220
-	 * @return boolean
220
+	 * @return boolean|null
221 221
 	 */
222 222
 	function set_unit_price( $unit_price ) {
223 223
 		$this->set( 'LIN_unit_price', $unit_price );
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 	/**
251 251
 	 * Gets percent (between 100-.001)
252
-	 * @return float
252
+	 * @return boolean
253 253
 	 */
254 254
 	function percent() {
255 255
 		return $this->get( 'LIN_percent' );
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 	/**
261 261
 	 * Sets percent (between 100-0.01)
262 262
 	 * @param float $percent
263
-	 * @return boolean
263
+	 * @return boolean|null
264 264
 	 */
265 265
 	function set_percent( $percent ) {
266 266
 		$this->set( 'LIN_percent', $percent );
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 	/**
272 272
 	 * Gets total
273
-	 * @return float
273
+	 * @return boolean
274 274
 	 */
275 275
 	function total() {
276 276
 		return $this->get( 'LIN_total' );
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	/**
282 282
 	 * Sets total
283 283
 	 * @param float $total
284
-	 * @return boolean
284
+	 * @return boolean|null
285 285
 	 */
286 286
 	function set_total( $total ) {
287 287
 		$this->set( 'LIN_total', $total );
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 
292 292
 	/**
293 293
 	 * Gets parent
294
-	 * @return int
294
+	 * @return boolean
295 295
 	 */
296 296
 	function parent_ID() {
297 297
 		return $this->get( 'LIN_parent' );
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 	/**
303 303
 	 * Sets parent
304 304
 	 * @param int $parent
305
-	 * @return boolean
305
+	 * @return boolean|null
306 306
 	 */
307 307
 	function set_parent_ID( $parent ) {
308 308
 		$this->set( 'LIN_parent', $parent );
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 
313 313
 	/**
314 314
 	 * Gets type
315
-	 * @return string
315
+	 * @return boolean
316 316
 	 */
317 317
 	function type() {
318 318
 		return $this->get( 'LIN_type' );
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 	/**
324 324
 	 * Sets type
325 325
 	 * @param string $type
326
-	 * @return boolean
326
+	 * @return boolean|null
327 327
 	 */
328 328
 	function set_type( $type ) {
329 329
 		$this->set( 'LIN_type', $type );
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
 	/**
362 362
 	 * Gets code
363
-	 * @return string
363
+	 * @return boolean
364 364
 	 */
365 365
 	function code() {
366 366
 		return $this->get( 'LIN_code' );
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 	/**
372 372
 	 * Sets code
373 373
 	 * @param string $code
374
-	 * @return boolean
374
+	 * @return boolean|null
375 375
 	 */
376 376
 	function set_code( $code ) {
377 377
 		$this->set( 'LIN_code', $code );
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
 	/**
393 393
 	 * Sets is_taxable
394 394
 	 * @param boolean $is_taxable
395
-	 * @return boolean
395
+	 * @return boolean|null
396 396
 	 */
397 397
 	function set_is_taxable( $is_taxable ) {
398 398
 		$this->set( 'LIN_is_taxable', $is_taxable );
@@ -670,7 +670,6 @@  discard block
 block discarded – undo
670 670
 	 * Recursively goes through all the children and recalculates sub-totals EXCEPT for
671 671
 	 * tax-sub-totals (they're a an odd beast). Updates the 'total' on each line item according to either its
672 672
 	 * unit price * quantity or the total of all its children EXCEPT when we're only calculating the taxable total and when this is called on the grand total
673
-	 * @param bool $include_taxable_items_only. If FALSE (default), updates the line items and sub-totals. If TRUE, just finds the amount taxable in this line item's price or its children's.
674 673
 	 * @throws EE_Error
675 674
 	 * @return float
676 675
 	 */
Please login to merge, or discard this patch.
Spacing   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 	 * @param string $timezone
42 42
 	 * @return EE_Line_Item
43 43
 	 */
44
-	public static function new_instance( $props_n_values = array(), $timezone = '' ) {
45
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
46
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
44
+	public static function new_instance($props_n_values = array(), $timezone = '') {
45
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
46
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
47 47
 	}
48 48
 
49 49
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 * @param string $timezone
54 54
 	 * @return EE_Line_Item
55 55
 	 */
56
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) {
57
-		return new self( $props_n_values, TRUE, $timezone );
56
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '') {
57
+		return new self($props_n_values, TRUE, $timezone);
58 58
 	}
59 59
 
60 60
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 	 * @param bool   $bydb
66 66
 	 * @param string $timezone
67 67
 	 */
68
-	protected function __construct( $fieldValues = array(), $bydb = FALSE, $timezone = '' ) {
69
-		parent::__construct( $fieldValues, $bydb, $timezone );
70
-		if ( !$this->get( 'LIN_code' ) ) {
71
-			$this->set_code( $this->generate_code() );
68
+	protected function __construct($fieldValues = array(), $bydb = FALSE, $timezone = '') {
69
+		parent::__construct($fieldValues, $bydb, $timezone);
70
+		if ( ! $this->get('LIN_code')) {
71
+			$this->set_code($this->generate_code());
72 72
 		}
73 73
 	}
74 74
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 * @return int
80 80
 	 */
81 81
 	function TXN_ID() {
82
-		return $this->get( 'TXN_ID' );
82
+		return $this->get('TXN_ID');
83 83
 	}
84 84
 
85 85
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 	 * @param int $TXN_ID
90 90
 	 * @return boolean
91 91
 	 */
92
-	function set_TXN_ID( $TXN_ID ) {
93
-		$this->set( 'TXN_ID', $TXN_ID );
92
+	function set_TXN_ID($TXN_ID) {
93
+		$this->set('TXN_ID', $TXN_ID);
94 94
 	}
95 95
 
96 96
 
@@ -100,9 +100,9 @@  discard block
 block discarded – undo
100 100
 	 * @return string
101 101
 	 */
102 102
 	function name() {
103
-		$name =  $this->get( 'LIN_name' );
104
-		if( ! $name ){
105
-			$name = ucwords( str_replace( '-', ' ', $this->type() ) );
103
+		$name = $this->get('LIN_name');
104
+		if ( ! $name) {
105
+			$name = ucwords(str_replace('-', ' ', $this->type()));
106 106
 		}
107 107
 		return $name;
108 108
 	}
@@ -114,8 +114,8 @@  discard block
 block discarded – undo
114 114
 	 * @param string $name
115 115
 	 * @return boolean
116 116
 	 */
117
-	function set_name( $name ) {
118
-		$this->set( 'LIN_name', $name );
117
+	function set_name($name) {
118
+		$this->set('LIN_name', $name);
119 119
 	}
120 120
 
121 121
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 * @return string
126 126
 	 */
127 127
 	function desc() {
128
-		return $this->get( 'LIN_desc' );
128
+		return $this->get('LIN_desc');
129 129
 	}
130 130
 
131 131
 
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @param string $desc
136 136
 	 * @return boolean
137 137
 	 */
138
-	function set_desc( $desc ) {
139
-		$this->set( 'LIN_desc', $desc );
138
+	function set_desc($desc) {
139
+		$this->set('LIN_desc', $desc);
140 140
 	}
141 141
 
142 142
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	 * @return int
147 147
 	 */
148 148
 	function quantity() {
149
-		return $this->get( 'LIN_quantity' );
149
+		return $this->get('LIN_quantity');
150 150
 	}
151 151
 
152 152
 
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	 * @param int $quantity
157 157
 	 * @return boolean
158 158
 	 */
159
-	function set_quantity( $quantity ) {
160
-		$this->set( 'LIN_quantity', $quantity );
159
+	function set_quantity($quantity) {
160
+		$this->set('LIN_quantity', $quantity);
161 161
 	}
162 162
 
163 163
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @return string
168 168
 	 */
169 169
 	function OBJ_ID() {
170
-		return $this->get( 'OBJ_ID' );
170
+		return $this->get('OBJ_ID');
171 171
 	}
172 172
 
173 173
 
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 	 * @param string $item_id
178 178
 	 * @return boolean
179 179
 	 */
180
-	function set_OBJ_ID( $item_id ) {
181
-		$this->set( 'OBJ_ID', $item_id );
180
+	function set_OBJ_ID($item_id) {
181
+		$this->set('OBJ_ID', $item_id);
182 182
 	}
183 183
 
184 184
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	 * @return string
189 189
 	 */
190 190
 	function OBJ_type() {
191
-		return $this->get( 'OBJ_type' );
191
+		return $this->get('OBJ_type');
192 192
 	}
193 193
 
194 194
 
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param string $OBJ_type
199 199
 	 * @return boolean
200 200
 	 */
201
-	function set_OBJ_type( $OBJ_type ) {
202
-		$this->set( 'OBJ_type', $OBJ_type );
201
+	function set_OBJ_type($OBJ_type) {
202
+		$this->set('OBJ_type', $OBJ_type);
203 203
 	}
204 204
 
205 205
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return float
210 210
 	 */
211 211
 	function unit_price() {
212
-		return $this->get( 'LIN_unit_price' );
212
+		return $this->get('LIN_unit_price');
213 213
 	}
214 214
 
215 215
 
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 * @param float $unit_price
220 220
 	 * @return boolean
221 221
 	 */
222
-	function set_unit_price( $unit_price ) {
223
-		$this->set( 'LIN_unit_price', $unit_price );
222
+	function set_unit_price($unit_price) {
223
+		$this->set('LIN_unit_price', $unit_price);
224 224
 	}
225 225
 
226 226
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 	 * @return boolean
232 232
 	 */
233 233
 	function is_percent() {
234
-		$unit_price = $this->get( 'LIN_unit_price' );
235
-		$percent = $this->get( 'LIN_percent' );
236
-		if ( $unit_price < .001 && $percent ) {
234
+		$unit_price = $this->get('LIN_unit_price');
235
+		$percent = $this->get('LIN_percent');
236
+		if ($unit_price < .001 && $percent) {
237 237
 			return TRUE;
238
-		} elseif ( $unit_price >= .001 && !$percent ) {
238
+		} elseif ($unit_price >= .001 && ! $percent) {
239 239
 			return FALSE;
240
-		} elseif ( $unit_price >= .001 && $percent ) {
241
-			throw new EE_Error( sprintf( __( "A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso" ), $unit_price, $percent ) );
240
+		} elseif ($unit_price >= .001 && $percent) {
241
+			throw new EE_Error(sprintf(__("A Line Item can not have a unit price of (%s) AND a percent (%s)!", "event_espresso"), $unit_price, $percent));
242 242
 		} else {
243 243
 			// if they're both 0, assume its not a percent item
244 244
 			return FALSE;
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	 * @return float
253 253
 	 */
254 254
 	function percent() {
255
-		return $this->get( 'LIN_percent' );
255
+		return $this->get('LIN_percent');
256 256
 	}
257 257
 
258 258
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @param float $percent
263 263
 	 * @return boolean
264 264
 	 */
265
-	function set_percent( $percent ) {
266
-		$this->set( 'LIN_percent', $percent );
265
+	function set_percent($percent) {
266
+		$this->set('LIN_percent', $percent);
267 267
 	}
268 268
 
269 269
 
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	 * @return float
274 274
 	 */
275 275
 	function total() {
276
-		return $this->get( 'LIN_total' );
276
+		return $this->get('LIN_total');
277 277
 	}
278 278
 
279 279
 
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param float $total
284 284
 	 * @return boolean
285 285
 	 */
286
-	function set_total( $total ) {
287
-		$this->set( 'LIN_total', $total );
286
+	function set_total($total) {
287
+		$this->set('LIN_total', $total);
288 288
 	}
289 289
 
290 290
 
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	 * @return int
295 295
 	 */
296 296
 	function parent_ID() {
297
-		return $this->get( 'LIN_parent' );
297
+		return $this->get('LIN_parent');
298 298
 	}
299 299
 
300 300
 
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 	 * @param int $parent
305 305
 	 * @return boolean
306 306
 	 */
307
-	function set_parent_ID( $parent ) {
308
-		$this->set( 'LIN_parent', $parent );
307
+	function set_parent_ID($parent) {
308
+		$this->set('LIN_parent', $parent);
309 309
 	}
310 310
 
311 311
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @return string
316 316
 	 */
317 317
 	function type() {
318
-		return $this->get( 'LIN_type' );
318
+		return $this->get('LIN_type');
319 319
 	}
320 320
 
321 321
 
@@ -325,8 +325,8 @@  discard block
 block discarded – undo
325 325
 	 * @param string $type
326 326
 	 * @return boolean
327 327
 	 */
328
-	function set_type( $type ) {
329
-		$this->set( 'LIN_type', $type );
328
+	function set_type($type) {
329
+		$this->set('LIN_type', $type);
330 330
 	}
331 331
 
332 332
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 * @return EE_Line_Item
337 337
 	 */
338 338
 	public function parent() {
339
-		return $this->get_model()->get_one_by_ID( $this->parent_ID() );
339
+		return $this->get_model()->get_one_by_ID($this->parent_ID());
340 340
 	}
341 341
 
342 342
 
@@ -346,10 +346,10 @@  discard block
 block discarded – undo
346 346
 	 * @return EE_Line_Item[]
347 347
 	 */
348 348
 	public function children() {
349
-		if ( $this->ID() ) {
350
-			return $this->get_model()->get_all( array( array( 'LIN_parent' => $this->ID() ) ) );
349
+		if ($this->ID()) {
350
+			return $this->get_model()->get_all(array(array('LIN_parent' => $this->ID())));
351 351
 		} else {
352
-			if ( !is_array( $this->_Line_Item ) ) {
352
+			if ( ! is_array($this->_Line_Item)) {
353 353
 				$this->_Line_Item = array();
354 354
 			}
355 355
 			return $this->_Line_Item;
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @return string
364 364
 	 */
365 365
 	function code() {
366
-		return $this->get( 'LIN_code' );
366
+		return $this->get('LIN_code');
367 367
 	}
368 368
 
369 369
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param string $code
374 374
 	 * @return boolean
375 375
 	 */
376
-	function set_code( $code ) {
377
-		$this->set( 'LIN_code', $code );
376
+	function set_code($code) {
377
+		$this->set('LIN_code', $code);
378 378
 	}
379 379
 
380 380
 
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 	 * @return boolean
385 385
 	 */
386 386
 	function is_taxable() {
387
-		return $this->get( 'LIN_is_taxable' );
387
+		return $this->get('LIN_is_taxable');
388 388
 	}
389 389
 
390 390
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param boolean $is_taxable
395 395
 	 * @return boolean
396 396
 	 */
397
-	function set_is_taxable( $is_taxable ) {
398
-		$this->set( 'LIN_is_taxable', $is_taxable );
397
+	function set_is_taxable($is_taxable) {
398
+		$this->set('LIN_is_taxable', $is_taxable);
399 399
 	}
400 400
 
401 401
 
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 	 */
408 408
 	function get_object() {
409 409
 		$model_name_of_related_obj = $this->OBJ_type();
410
-		$is_model_name = EE_Registry::instance()->is_model_name( $model_name_of_related_obj );
411
-		if ( !$is_model_name ) {
410
+		$is_model_name = EE_Registry::instance()->is_model_name($model_name_of_related_obj);
411
+		if ( ! $is_model_name) {
412 412
 			return NULL;
413 413
 		} else {
414
-			return $this->get_first_related( $model_name_of_related_obj );
414
+			return $this->get_first_related($model_name_of_related_obj);
415 415
 		}
416 416
 	}
417 417
 
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	 * @param array $query_params
424 424
 	 * @return EE_Ticket
425 425
 	 */
426
-	function ticket( $query_params = array() ) {
426
+	function ticket($query_params = array()) {
427 427
 		//we're going to assume that when this method is called we always want to receive the attached ticket EVEN if that ticket is archived.  This can be overridden via the incoming $query_params argument
428
-		$remove_defaults = array( 'default_where_conditions' => 'none' );
429
-		$query_params = array_merge( $remove_defaults, $query_params );
430
-		return $this->get_first_related( 'Ticket', $query_params );
428
+		$remove_defaults = array('default_where_conditions' => 'none');
429
+		$query_params = array_merge($remove_defaults, $query_params);
430
+		return $this->get_first_related('Ticket', $query_params);
431 431
 	}
432 432
 
433 433
 
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 	 * @return string
439 439
 	 */
440 440
 	function ticket_event_name() {
441
-		$event_name = __( "Unknown", "event_espresso" );
441
+		$event_name = __("Unknown", "event_espresso");
442 442
 		$ticket = $this->ticket();
443
-		if ( $ticket ) {
443
+		if ($ticket) {
444 444
 			$datetime = $ticket->first_datetime();
445
-			if ( $datetime instanceof EE_Datetime ) {
445
+			if ($datetime instanceof EE_Datetime) {
446 446
 				$event = $datetime->event();
447
-				if ( $event instanceof EE_Event ) {
447
+				if ($event instanceof EE_Event) {
448 448
 					$event_name = $event->name();
449 449
 				}
450 450
 			}
@@ -460,13 +460,13 @@  discard block
 block discarded – undo
460 460
 	 * @param string $time_format
461 461
 	 * @return string
462 462
 	 */
463
-	function ticket_datetime_start( $date_format = '', $time_format = '' ) {
464
-		$first_datetime_string = __( "Unknown", "event_espresso" );
463
+	function ticket_datetime_start($date_format = '', $time_format = '') {
464
+		$first_datetime_string = __("Unknown", "event_espresso");
465 465
 		$ticket = $this->ticket();
466
-		if ( $ticket instanceof EE_Ticket ) {
466
+		if ($ticket instanceof EE_Ticket) {
467 467
 			$first_datetime = $ticket->first_datetime();
468
-			if ( $first_datetime ) {
469
-				$first_datetime_string = $first_datetime->start_date_and_time( $date_format, $time_format );
468
+			if ($first_datetime) {
469
+				$first_datetime_string = $first_datetime->start_date_and_time($date_format, $time_format);
470 470
 			}
471 471
 		}
472 472
 		return $first_datetime_string;
@@ -480,20 +480,20 @@  discard block
 block discarded – undo
480 480
 	 * @param EE_Line_Item $line_item
481 481
 	 * @return boolean success
482 482
 	 */
483
-	function add_child_line_item( EE_Line_Item $line_item ) {
484
-		if ( $this->ID() ) {
483
+	function add_child_line_item(EE_Line_Item $line_item) {
484
+		if ($this->ID()) {
485 485
 			//check for any duplicate line items (with the same code), if so, thsi replaces it
486
-			$line_item_with_same_code = $this->get_child_line_item(  $line_item->code() );
487
-			if( $line_item_with_same_code instanceof EE_Line_Item ) {
488
-				$this->delete_child_line_item( $line_item_with_same_code->code() );
486
+			$line_item_with_same_code = $this->get_child_line_item($line_item->code());
487
+			if ($line_item_with_same_code instanceof EE_Line_Item) {
488
+				$this->delete_child_line_item($line_item_with_same_code->code());
489 489
 			}
490
-			$line_item->set_parent_ID( $this->ID() );
491
-			if( $this->TXN_ID() ){
492
-				$line_item->set_TXN_ID( $this->TXN_ID() );
490
+			$line_item->set_parent_ID($this->ID());
491
+			if ($this->TXN_ID()) {
492
+				$line_item->set_TXN_ID($this->TXN_ID());
493 493
 			}
494 494
 			return $line_item->save();
495 495
 		} else {
496
-			$this->_Line_Item[ $line_item->code() ] = $line_item;
496
+			$this->_Line_Item[$line_item->code()] = $line_item;
497 497
 			return TRUE;
498 498
 		}
499 499
 	}
@@ -507,11 +507,11 @@  discard block
 block discarded – undo
507 507
 	 * @param string $code
508 508
 	 * @return EE_Line_Item
509 509
 	 */
510
-	function get_child_line_item( $code ) {
511
-		if ( $this->ID() ) {
512
-			return $this->get_model()->get_one( array( array( 'LIN_parent' => $this->ID(), 'LIN_code' => $code ) ) );
510
+	function get_child_line_item($code) {
511
+		if ($this->ID()) {
512
+			return $this->get_model()->get_one(array(array('LIN_parent' => $this->ID(), 'LIN_code' => $code)));
513 513
 		} else {
514
-			return $this->_Line_Item[ $code ];
514
+			return $this->_Line_Item[$code];
515 515
 		}
516 516
 	}
517 517
 
@@ -522,10 +522,10 @@  discard block
 block discarded – undo
522 522
 	 * @return int
523 523
 	 */
524 524
 	function delete_children_line_items() {
525
-		if ( $this->ID() ) {
526
-			return $this->get_model()->delete( array( array( 'LIN_parent' => $this->ID() ) ) );
525
+		if ($this->ID()) {
526
+			return $this->get_model()->delete(array(array('LIN_parent' => $this->ID())));
527 527
 		} else {
528
-			$count = count( $this->_Line_Item );
528
+			$count = count($this->_Line_Item);
529 529
 			$this->_Line_Item = array();
530 530
 			return $count;
531 531
 		}
@@ -539,11 +539,11 @@  discard block
 block discarded – undo
539 539
 	 * @param string $code
540 540
 	 * @return int count of items deleted (or simply removed from the line item's cache, if not has not been saved to the DB yet)
541 541
 	 */
542
-	function delete_child_line_item( $code ) {
543
-		if ( $this->ID() ) {
544
-			return $this->get_model()->delete( array( array( 'LIN_code' => $code, 'LIN_parent' => $this->ID() ) ) );
542
+	function delete_child_line_item($code) {
543
+		if ($this->ID()) {
544
+			return $this->get_model()->delete(array(array('LIN_code' => $code, 'LIN_parent' => $this->ID())));
545 545
 		} else {
546
-			unset( $this->_Line_Item[ $code ] );
546
+			unset($this->_Line_Item[$code]);
547 547
 			return 1;
548 548
 		}
549 549
 	}
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 	 */
557 557
 	function generate_code() {
558 558
 		// each line item in the cart requires a unique identifier
559
-		return md5( $this->get( 'OBJ_type' ) . $this->get( 'OBJ_ID' ) . time() );
559
+		return md5($this->get('OBJ_type').$this->get('OBJ_ID').time());
560 560
 	}
561 561
 
562 562
 
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @return string like '2, 004.00', formatted according to the localized currency
621 621
 	 */
622 622
 	function unit_price_no_code() {
623
-		return $this->get_pretty( 'LIN_unit_price', 'no_currency_code' );
623
+		return $this->get_pretty('LIN_unit_price', 'no_currency_code');
624 624
 	}
625 625
 
626 626
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * @return string like '2, 004.00', formatted according to the localized currency
631 631
 	 */
632 632
 	function total_no_code() {
633
-		return $this->get_pretty( 'LIN_total', 'no_currency_code' );
633
+		return $this->get_pretty('LIN_total', 'no_currency_code');
634 634
 	}
635 635
 
636 636
 
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 		$pre_tax_total = $this->recalculate_pre_tax_total();
647 647
 		$tax_total = $this->recalculate_taxes_and_tax_total();
648 648
 		$total = $pre_tax_total + $tax_total;
649
-		$this->set_total( $total );
650
-		if( $this->type() == EEM_Line_Item::type_total && $this->transaction() instanceof EE_Transaction ){
651
-			$this->transaction()->set_total( $total );
649
+		$this->set_total($total);
650
+		if ($this->type() == EEM_Line_Item::type_total && $this->transaction() instanceof EE_Transaction) {
651
+			$this->transaction()->set_total($total);
652 652
 		}
653 653
 		return $total;
654 654
 	}
@@ -666,20 +666,20 @@  discard block
 block discarded – undo
666 666
 	function recalculate_pre_tax_total( ) {
667 667
 		$total = 0;
668 668
 		//completely ignore tax sub-totals when calculating the pre-tax-total
669
-		if ( $this->is_tax_sub_total() ) {
669
+		if ($this->is_tax_sub_total()) {
670 670
 			return 0;
671
-		} elseif ( $this->is_sub_line_item() ) {
672
-			throw new EE_Error( sprintf( __( "Calculating the pretax-total on subline items doesn't make sense right now. You were trying to calculate it on %s", "event_espresso" ), d( $this ) ) );
673
-		} elseif ( $this->is_line_item() ) {
671
+		} elseif ($this->is_sub_line_item()) {
672
+			throw new EE_Error(sprintf(__("Calculating the pretax-total on subline items doesn't make sense right now. You were trying to calculate it on %s", "event_espresso"), d($this)));
673
+		} elseif ($this->is_line_item()) {
674 674
 			//we'll want to attach promotions here too. So maybe, if the line item has children, we'll need to take them into account too
675 675
 			$total = $this->unit_price() * $this->quantity();
676
-			$this->set_total( $total );
677
-		} elseif ( $this->is_sub_total() || $this->is_total() ) {
676
+			$this->set_total($total);
677
+		} elseif ($this->is_sub_total() || $this->is_total()) {
678 678
 			//get the total of all its children
679
-			foreach ( $this->children() as $child_line_item ) {
680
-				if ( $child_line_item instanceof EE_Line_Item ) {
679
+			foreach ($this->children() as $child_line_item) {
680
+				if ($child_line_item instanceof EE_Line_Item) {
681 681
 					//only recalculate sub-totals for NON-taxes
682
-					if ( $child_line_item->is_percent() ) {
682
+					if ($child_line_item->is_percent()) {
683 683
 						$total += $total * $child_line_item->percent() / 100;
684 684
 					} else {
685 685
 						$total += $child_line_item->recalculate_pre_tax_total();
@@ -688,8 +688,8 @@  discard block
 block discarded – undo
688 688
 			}
689 689
 			//we only want to update sub-totals if we're including non-taxable items
690 690
 			//and grand totals shouldn't be updated when calculating pre-tax totals
691
-			if( $this->is_sub_total() ){
692
-				$this->set_total( $total );
691
+			if ($this->is_sub_total()) {
692
+				$this->set_total($total);
693 693
 			}
694 694
 		}
695 695
 		return $total;
@@ -708,10 +708,10 @@  discard block
 block discarded – undo
708 708
 		//calculate the pretax total
709 709
 		$taxable_total = $this->taxable_total();
710 710
 		$tax_total = 0;
711
-		foreach ( $taxes as $tax ) {
711
+		foreach ($taxes as $tax) {
712 712
 			$total_on_this_tax = $taxable_total * $tax->percent() / 100;
713 713
 			//remember the total on this line item
714
-			$tax->set_total( $total_on_this_tax );
714
+			$tax->set_total($total_on_this_tax);
715 715
 			$tax_total += $tax->total();
716 716
 		}
717 717
 		$this->_recalculate_tax_sub_total();
@@ -725,18 +725,18 @@  discard block
 block discarded – undo
725 725
 	 * @return void
726 726
 	 */
727 727
 	private function _recalculate_tax_sub_total() {
728
-		if ( $this->is_tax_sub_total() ) {
728
+		if ($this->is_tax_sub_total()) {
729 729
 			$total = 0;
730 730
 			//simply loop through all its children (which should be taxes) and sum their total
731
-			foreach ( $this->children() as $child_tax ) {
732
-				if ( $child_tax instanceof EE_Line_Item ) {
731
+			foreach ($this->children() as $child_tax) {
732
+				if ($child_tax instanceof EE_Line_Item) {
733 733
 					$total += $child_tax->total();
734 734
 				}
735 735
 			}
736
-			$this->set_total( $total );
737
-		} elseif ( $this->is_total() ) {
738
-			foreach ( $this->children() as $maybe_tax_subtotal ) {
739
-				if ( $maybe_tax_subtotal instanceof EE_Line_Item ) {
736
+			$this->set_total($total);
737
+		} elseif ($this->is_total()) {
738
+			foreach ($this->children() as $maybe_tax_subtotal) {
739
+				if ($maybe_tax_subtotal instanceof EE_Line_Item) {
740 740
 					$maybe_tax_subtotal->_recalculate_tax_sub_total();
741 741
 				}
742 742
 			}
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	public function get_total_tax() {
753 753
 		$this->_recalculate_tax_sub_total();
754 754
 		$total = 0;
755
-		foreach ( $this->tax_descendants() as $tax_line_item ) {
755
+		foreach ($this->tax_descendants() as $tax_line_item) {
756 756
 			$total += $tax_line_item->total();
757 757
 		}
758 758
 		return $total;
@@ -765,8 +765,8 @@  discard block
 block discarded – undo
765 765
 	 */
766 766
 	public function get_items_total() {
767 767
 		$total = 0;
768
-		foreach ( $this->_get_descendants_of_type( EEM_Line_Item::type_line_item ) as $item ) {
769
-			if ( $item instanceof EE_Line_Item ) {
768
+		foreach ($this->_get_descendants_of_type(EEM_Line_Item::type_line_item) as $item) {
769
+			if ($item instanceof EE_Line_Item) {
770 770
 				$total += $item->total();
771 771
 			}
772 772
 		}
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 	 * @return EE_Line_Item[]
782 782
 	 */
783 783
 	function tax_descendants() {
784
-		return $this->_get_descendants_of_type( EEM_Line_Item::type_tax );
784
+		return $this->_get_descendants_of_type(EEM_Line_Item::type_tax);
785 785
 	}
786 786
 
787 787
 
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	 * @return EE_Line_Item[]
792 792
 	 */
793 793
 	function get_items() {
794
-		return $this->_get_descendants_of_type( EEM_Line_Item::type_line_item );
794
+		return $this->_get_descendants_of_type(EEM_Line_Item::type_line_item);
795 795
 	}
796 796
 
797 797
 
@@ -801,15 +801,15 @@  discard block
 block discarded – undo
801 801
 	 * @param string $type one of the constants on EEM_Line_Item
802 802
 	 * @return EE_Line_Item[]
803 803
 	 */
804
-	protected function _get_descendants_of_type( $type ) {
804
+	protected function _get_descendants_of_type($type) {
805 805
 		$line_items_of_type = array();
806
-		foreach ( $this->children() as $child_line_item ) {
807
-			if ( $child_line_item instanceof EE_Line_Item ) {
808
-				if ( $child_line_item->type() == $type ) {
809
-					$line_items_of_type[ ] = $child_line_item;
806
+		foreach ($this->children() as $child_line_item) {
807
+			if ($child_line_item instanceof EE_Line_Item) {
808
+				if ($child_line_item->type() == $type) {
809
+					$line_items_of_type[] = $child_line_item;
810 810
 				} else {
811 811
 					//go-through-all-its children looking for taxes
812
-					$line_items_of_type = array_merge( $line_items_of_type, $child_line_item->_get_descendants_of_type( $type ) );
812
+					$line_items_of_type = array_merge($line_items_of_type, $child_line_item->_get_descendants_of_type($type));
813 813
 				}
814 814
 			}
815 815
 		}
@@ -822,15 +822,15 @@  discard block
 block discarded – undo
822 822
 	 * @param string $type like one of the EEM_Line_Item::type_*
823 823
 	 * @return EE_Line_Item
824 824
 	 */
825
-	public function get_nearest_descendant_of_type( $type ) {
826
-		foreach( $this->children() as $child ){
827
-			if( $child->type() == $type ){
825
+	public function get_nearest_descendant_of_type($type) {
826
+		foreach ($this->children() as $child) {
827
+			if ($child->type() == $type) {
828 828
 				return $child;
829 829
 			}
830 830
 		}
831
-		foreach($this->children() as $child ){
832
-			$descendant_found = $child->get_nearest_descendant_of_type( $type );
833
-			if( $descendant_found ){
831
+		foreach ($this->children() as $child) {
832
+			$descendant_found = $child->get_nearest_descendant_of_type($type);
833
+			if ($descendant_found) {
834 834
 				return $descendant_found;
835 835
 			}
836 836
 		}
@@ -846,12 +846,12 @@  discard block
 block discarded – undo
846 846
 	 */
847 847
 	function taxable_total() {
848 848
 		$total = 0;
849
-		if ( $this->children() ) {
850
-			foreach ( $this->children() as $child_line_item ) {
849
+		if ($this->children()) {
850
+			foreach ($this->children() as $child_line_item) {
851 851
 
852
-				if ( $child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
852
+				if ($child_line_item->type() == EEM_Line_Item::type_line_item && $child_line_item->is_taxable()) {
853 853
 					$total += $child_line_item->total();
854
-				}elseif( $child_line_item->type() == EEM_Line_Item::type_sub_total ){
854
+				}elseif ($child_line_item->type() == EEM_Line_Item::type_sub_total) {
855 855
 					$total += $child_line_item->taxable_total();
856 856
 				}
857 857
 			}
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 	 * @return EE_Transaction
867 867
 	 */
868 868
 	public function transaction() {
869
-		return $this->get_first_related( 'Transaction' );
869
+		return $this->get_first_related('Transaction');
870 870
 	}
871 871
 
872 872
 
@@ -879,17 +879,17 @@  discard block
 block discarded – undo
879 879
 	 * @param int $txn_id if none is provided, assumes $this->TXN_ID()
880 880
 	 * @return int count of items saved
881 881
 	 */
882
-	public function save_this_and_descendants_to_txn( $txn_id = NULL ) {
883
-		if ( ! $txn_id ) {
882
+	public function save_this_and_descendants_to_txn($txn_id = NULL) {
883
+		if ( ! $txn_id) {
884 884
 			$txn_id = $this->TXN_ID();
885 885
 		}
886
-		$this->set_TXN_ID( $txn_id );
886
+		$this->set_TXN_ID($txn_id);
887 887
 		$children = $this->children();
888 888
 		$this->save();
889
-		foreach ( $children as $child_line_item ) {
890
-			if ( $child_line_item instanceof EE_Line_Item ) {
891
-				$child_line_item->set_parent_ID( $this->ID() );
892
-				$child_line_item->save_this_and_descendants_to_txn( $txn_id );
889
+		foreach ($children as $child_line_item) {
890
+			if ($child_line_item instanceof EE_Line_Item) {
891
+				$child_line_item->set_parent_ID($this->ID());
892
+				$child_line_item->save_this_and_descendants_to_txn($txn_id);
893 893
 			}
894 894
 		}
895 895
 	}
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, current_time('timestamp'), $timezone )
56
+				'CHK_timestamp'=>new EE_Datetime_Field('CHK_timestamp', __('When the row was modified', 'event_espresso'), false, current_time('timestamp'), $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_Event.model.php 3 patches
Braces   +12 added lines, -7 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
  *
@@ -337,8 +339,9 @@  discard block
 block discarded – undo
337 339
 			 	$questions[ $qg->ID() ] = $qg->model_field_array();
338 340
 			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
339 341
 			 	foreach ( $qsts as $qst ) {
340
-			 		if ( $qst->is_system_question() )
341
-			 			continue;
342
+			 		if ( $qst->is_system_question() ) {
343
+			 					 			continue;
344
+			 		}
342 345
 			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
343 346
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
344 347
 			 		$qst_name = $qstn_id = $qst->ID();
@@ -514,8 +517,9 @@  discard block
 block discarded – undo
514 517
 		}
515 518
 
516 519
 		//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.
517
-		if ( isset( $where_params['status'] ) )
518
-			unset( $where_params['status'] );
520
+		if ( isset( $where_params['status'] ) ) {
521
+					unset( $where_params['status'] );
522
+		}
519 523
 		$where_params['OR'] = array( 'status' => array( '!=', 'publish' ), 'AND' => array('status' => 'publish', 'Datetime.DTT_EVT_end' => array( '<',  date('Y-m-d g:i:s', time() ) ) ) );
520 524
 		$query_params[0] = $where_params;
521 525
 		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all( $query_params );
@@ -538,8 +542,9 @@  discard block
 block discarded – undo
538 542
 		}
539 543
 
540 544
 		//let's add in specific query_params for inactive events.
541
-		if ( isset( $where_params['status'] ) )
542
-			unset( $where_params['status'] );
545
+		if ( isset( $where_params['status'] ) ) {
546
+					unset( $where_params['status'] );
547
+		}
543 548
 
544 549
 		//we check for events that are not published OR are expired.
545 550
 
Please login to merge, or discard this patch.
Spacing   +124 added lines, -124 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
@@ -45,15 +45,15 @@  discard block
 block discarded – undo
45 45
 	 * @param string $timezone
46 46
 	 * @return EEM_Event
47 47
 	 */
48
-	public static function instance( $timezone = NULL ){
48
+	public static function instance($timezone = NULL) {
49 49
 
50 50
 		// check if instance of EEM_Event already exists
51
-		if ( ! self::$_instance instanceof EEM_Event ) {
51
+		if ( ! self::$_instance instanceof EEM_Event) {
52 52
 			// instantiate Espresso_model
53
-			self::$_instance = new self( $timezone );
53
+			self::$_instance = new self($timezone);
54 54
 		}
55 55
 		//we might have a timezone set, let set_timezone decide what to do with it
56
-		self::$_instance->set_timezone( $timezone );
56
+		self::$_instance->set_timezone($timezone);
57 57
 		// EEM_Event object
58 58
 		return self::$_instance;
59 59
 	}
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	 * @param string $timezone
65 65
 	 * @return EEM_Event
66 66
 	 */
67
-	protected function __construct($timezone = null){
67
+	protected function __construct($timezone = null) {
68 68
 
69
-		EE_Registry::instance()->load_model( 'Registration' );
69
+		EE_Registry::instance()->load_model('Registration');
70 70
 
71
-		$this->singular_item = __('Event','event_espresso');
72
-		$this->plural_item = __('Events','event_espresso');
71
+		$this->singular_item = __('Event', 'event_espresso');
72
+		$this->plural_item = __('Events', 'event_espresso');
73 73
 
74 74
 		// to remove Cancelled events from the frontend, copy the following filter to your functions.php file
75 75
 		// add_filter( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', '__return_false' );
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
 			array(
84 84
 				EEM_Event::cancelled => array(
85 85
 					'label' => __('Cancelled', 'event_espresso'),
86
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE )
86
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__cancelled__Public', TRUE)
87 87
 				),
88 88
 				EEM_Event::postponed => array(
89 89
 					'label' => __('Postponed', 'event_espresso'),
90
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE )
90
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__postponed__Public', TRUE)
91 91
 				),
92 92
 				EEM_Event::sold_out => array(
93 93
 					'label' => __('Sold Out', 'event_espresso'),
94
-					'public' => apply_filters( 'AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE )
94
+					'public' => apply_filters('AFEE__EEM_Event__construct___custom_stati__sold_out__Public', TRUE)
95 95
 				)
96 96
 			)
97 97
 		);
@@ -99,41 +99,41 @@  discard block
 block discarded – undo
99 99
 		$default_registration_status = EE_Registry::instance()->CFG->registration instanceof EE_Registration_Config ? EE_Registry::instance()->CFG->registration->default_STS_ID : EEM_Registration::status_id_pending_payment;
100 100
 
101 101
 		$this->_tables = array(
102
-			'Event_CPT'=>new EE_Primary_Table( 'posts','ID' ),
103
-			'Event_Meta'=> new EE_Secondary_Table( 'esp_event_meta', 'EVTM_ID', 'EVT_ID' )
102
+			'Event_CPT'=>new EE_Primary_Table('posts', 'ID'),
103
+			'Event_Meta'=> new EE_Secondary_Table('esp_event_meta', 'EVTM_ID', 'EVT_ID')
104 104
 		);
105 105
 
106 106
 		$this->_fields = array(
107 107
 			'Event_CPT'=>array(
108
-				'EVT_ID'=>new EE_Primary_Key_Int_Field( 'ID', __( 'Post ID for Event','event_espresso' )),
109
-				'EVT_name'=>new EE_Plain_Text_Field( 'post_title', __( 'Event Name','event_espresso' ), FALSE, '' ),
110
-				'EVT_desc'=>new EE_Post_Content_Field( 'post_content', __( 'Event Description', 'event_espresso' ), FALSE, '' ),
111
-				'EVT_slug'=>new EE_Slug_Field( 'post_name', __( 'Event Slug', 'event_espresso' ), FALSE, '' ),
112
-				'EVT_created'=>new EE_Datetime_Field( 'post_date', __( 'Date/Time Event Created', 'event_espresso' ), FALSE, current_time( 'timestamp' )),
113
-				'EVT_short_desc'=>new EE_Simple_HTML_Field( 'post_excerpt', __( 'Event Short Description', 'event_espresso' ), FALSE,'' ),
114
-				'EVT_modified'=>new EE_Datetime_Field( 'post_modified', __( 'Date/Time Event Modified', 'event_espresso' ), FALSE, current_time( 'timestamp' )),
115
-				'EVT_wp_user'=>new EE_WP_User_Field( 'post_author', __( 'Event Creator ID', 'event_espresso'), FALSE),
116
-				'parent'=>new EE_Integer_Field( 'post_parent', __( 'Event Parent ID', 'event_espresso' ), FALSE, 0 ),
117
-				'EVT_order'=>new EE_Integer_Field( 'menu_order', __( 'Event Menu Order', 'event_espresso' ), FALSE, 1 ),
118
-				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'),// EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
119
-				'status' => new EE_WP_Post_Status_Field( 'post_status', __( 'Event Status', 'event_espresso' ), FALSE, 'draft', $this->_custom_stati )
108
+				'EVT_ID'=>new EE_Primary_Key_Int_Field('ID', __('Post ID for Event', 'event_espresso')),
109
+				'EVT_name'=>new EE_Plain_Text_Field('post_title', __('Event Name', 'event_espresso'), FALSE, ''),
110
+				'EVT_desc'=>new EE_Post_Content_Field('post_content', __('Event Description', 'event_espresso'), FALSE, ''),
111
+				'EVT_slug'=>new EE_Slug_Field('post_name', __('Event Slug', 'event_espresso'), FALSE, ''),
112
+				'EVT_created'=>new EE_Datetime_Field('post_date', __('Date/Time Event Created', 'event_espresso'), FALSE, current_time('timestamp')),
113
+				'EVT_short_desc'=>new EE_Simple_HTML_Field('post_excerpt', __('Event Short Description', 'event_espresso'), FALSE, ''),
114
+				'EVT_modified'=>new EE_Datetime_Field('post_modified', __('Date/Time Event Modified', 'event_espresso'), FALSE, current_time('timestamp')),
115
+				'EVT_wp_user'=>new EE_WP_User_Field('post_author', __('Event Creator ID', 'event_espresso'), FALSE),
116
+				'parent'=>new EE_Integer_Field('post_parent', __('Event Parent ID', 'event_espresso'), FALSE, 0),
117
+				'EVT_order'=>new EE_Integer_Field('menu_order', __('Event Menu Order', 'event_espresso'), FALSE, 1),
118
+				'post_type'=>new EE_WP_Post_Type_Field('espresso_events'), // EE_Plain_Text_Field( 'post_type', __( 'Event Post Type', 'event_espresso' ), FALSE, 'espresso_events' ),
119
+				'status' => new EE_WP_Post_Status_Field('post_status', __('Event Status', 'event_espresso'), FALSE, 'draft', $this->_custom_stati)
120 120
 			),
121 121
 			'Event_Meta'=>array(
122
-				'EVTM_ID'=> new EE_DB_Only_Float_Field( 'EVTM_ID', __( 'Event Meta Row ID','event_espresso' ), FALSE ),
123
-				'EVT_ID_fk'=>new EE_DB_Only_Int_Field( 'EVT_ID', __( 'Foreign key to Event ID from Event Meta table', 'event_espresso' ), FALSE ),
124
-				'EVT_display_desc'=>new EE_Boolean_Field( 'EVT_display_desc', __( 'Display Description Flag', 'event_espresso' ), FALSE, 1 ),
125
-				'EVT_display_ticket_selector'=>new EE_Boolean_Field( 'EVT_display_ticket_selector', __( 'Display Ticket Selector Flag', 'event_espresso' ), FALSE, 1 ),
126
-				'EVT_visible_on'=>new EE_Datetime_Field( 'EVT_visible_on', __( 'Event Visible Date', 'event_espresso' ), TRUE, current_time( 'timestamp' )),
127
-				'EVT_additional_limit'=>new EE_Integer_Field( 'EVT_additional_limit', __( 'Limit of Additional Registrations on Same Transaction', 'event_espresso' ), TRUE, 10 ),
122
+				'EVTM_ID'=> new EE_DB_Only_Float_Field('EVTM_ID', __('Event Meta Row ID', 'event_espresso'), FALSE),
123
+				'EVT_ID_fk'=>new EE_DB_Only_Int_Field('EVT_ID', __('Foreign key to Event ID from Event Meta table', 'event_espresso'), FALSE),
124
+				'EVT_display_desc'=>new EE_Boolean_Field('EVT_display_desc', __('Display Description Flag', 'event_espresso'), FALSE, 1),
125
+				'EVT_display_ticket_selector'=>new EE_Boolean_Field('EVT_display_ticket_selector', __('Display Ticket Selector Flag', 'event_espresso'), FALSE, 1),
126
+				'EVT_visible_on'=>new EE_Datetime_Field('EVT_visible_on', __('Event Visible Date', 'event_espresso'), TRUE, current_time('timestamp')),
127
+				'EVT_additional_limit'=>new EE_Integer_Field('EVT_additional_limit', __('Limit of Additional Registrations on Same Transaction', 'event_espresso'), TRUE, 10),
128 128
 				'EVT_default_registration_status'=>new EE_Enum_Text_Field(
129
-					'EVT_default_registration_status', __( 'Default Registration Status on this Event', 'event_espresso' ), FALSE, $default_registration_status, EEM_Registration::reg_status_array()
129
+					'EVT_default_registration_status', __('Default Registration Status on this Event', 'event_espresso'), FALSE, $default_registration_status, EEM_Registration::reg_status_array()
130 130
 				),
131
-				'EVT_member_only'=>new EE_Boolean_Field( 'EVT_member_only', __( 'Member-Only Event Flag', 'event_espresso' ), FALSE, FALSE ),
132
-				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __( 'Event Phone Number', 'event_espresso' ), FALSE ),
133
-				'EVT_allow_overflow'=>new EE_Boolean_Field(  'EVT_allow_overflow', __( 'Allow Overflow on Event', 'event_espresso' ), FALSE, FALSE ),
134
-				'EVT_timezone_string'=>new EE_Plain_Text_Field( 'EVT_timezone_string', __( 'Timezone (name) for Event times', 'event_espresso' ), FALSE ),
135
-				'EVT_external_URL'=>new EE_Plain_Text_Field( 'EVT_external_URL', __( 'URL of Event Page if hosted elsewhere', 'event_espresso' ), TRUE ),
136
-				'EVT_donations'=>new EE_Boolean_Field( 'EVT_donations', __( 'Accept Donations?', 'event_espresso' ), FALSE, FALSE )
131
+				'EVT_member_only'=>new EE_Boolean_Field('EVT_member_only', __('Member-Only Event Flag', 'event_espresso'), FALSE, FALSE),
132
+				'EVT_phone'=> new EE_Plain_Text_Field('EVT_phone', __('Event Phone Number', 'event_espresso'), FALSE),
133
+				'EVT_allow_overflow'=>new EE_Boolean_Field('EVT_allow_overflow', __('Allow Overflow on Event', 'event_espresso'), FALSE, FALSE),
134
+				'EVT_timezone_string'=>new EE_Plain_Text_Field('EVT_timezone_string', __('Timezone (name) for Event times', 'event_espresso'), FALSE),
135
+				'EVT_external_URL'=>new EE_Plain_Text_Field('EVT_external_URL', __('URL of Event Page if hosted elsewhere', 'event_espresso'), TRUE),
136
+				'EVT_donations'=>new EE_Boolean_Field('EVT_donations', __('Accept Donations?', 'event_espresso'), FALSE, FALSE)
137 137
 
138 138
 			));
139 139
 
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		);
150 150
 
151 151
 		$this->_default_where_conditions_strategy = new EE_CPT_Where_Conditions('espresso_events', 'EVTM_ID');
152
-		parent::__construct( $timezone );
152
+		parent::__construct($timezone);
153 153
 	}
154 154
 
155 155
 
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 	*		@return 		array
165 165
 	*/
166 166
 	public function get_all_question_groups() {
167
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
168
-			array( 'QSG_deleted' => FALSE ),
169
-			'order_by' => array( 'QSG_order' => 'ASC' )
167
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
168
+			array('QSG_deleted' => FALSE),
169
+			'order_by' => array('QSG_order' => 'ASC')
170 170
 		));
171 171
 	}
172 172
 
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	* 		@param		int $EVT_ID
183 183
 	*		@return 		array
184 184
 	*/
185
-	public function get_all_event_question_groups( $EVT_ID = 0 ) {
186
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
187
-			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__ );
185
+	public function get_all_event_question_groups($EVT_ID = 0) {
186
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
187
+			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__);
188 188
 			return FALSE;
189 189
 		}
190
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
191
-			array( 'EVT_ID' => $EVT_ID )
190
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
191
+			array('EVT_ID' => $EVT_ID)
192 192
 		));
193 193
 	}
194 194
 
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
 	* 		@param		boolean	$for_primary_attendee
205 205
 	*		@return 		array
206 206
 	*/
207
-	public function get_event_question_groups( $EVT_ID = 0, $for_primary_attendee = TRUE ) {
208
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
209
-			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
+	public function get_event_question_groups($EVT_ID = 0, $for_primary_attendee = TRUE) {
208
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
209
+			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__);
210 210
 			return FALSE;
211 211
 		}
212
-		return EE_Registry::instance()->load_model( 'Event_Question_Group' )->get_all( array(
213
-			array( 'EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee )
212
+		return EE_Registry::instance()->load_model('Event_Question_Group')->get_all(array(
213
+			array('EVT_ID' => $EVT_ID, 'EQG_primary' => $for_primary_attendee)
214 214
 		));
215 215
 	}
216 216
 
@@ -227,10 +227,10 @@  discard block
 block discarded – undo
227 227
 	* 		@param		EE_Registration 	$registration
228 228
 	*		@return 		array
229 229
 	*/
230
-	public function get_question_groups_for_event( $EVT_ID = 0, EE_Registration $registration ) {
230
+	public function get_question_groups_for_event($EVT_ID = 0, EE_Registration $registration) {
231 231
 
232
-		if ( ! isset( $EVT_ID) || ! absint( $EVT_ID )) {
233
-			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__ );
232
+		if ( ! isset($EVT_ID) || ! absint($EVT_ID)) {
233
+			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__);
234 234
 			return FALSE;
235 235
 		}
236 236
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 			'QSG_deleted' => FALSE
241 241
 		);
242 242
 
243
-		return EE_Registry::instance()->load_model( 'Question_Group' )->get_all( array(
243
+		return EE_Registry::instance()->load_model('Question_Group')->get_all(array(
244 244
 			$where_params,
245 245
 			'order_by' => array('QSG_order' => 'ASC')
246 246
 		));
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
 	* 		@param		string		$QSG_IDs  csv list of $QSG IDs
261 261
 	*		@return 		array
262 262
 	*/
263
-	public function get_questions_in_groups( $QSG_IDs = '' ) {
263
+	public function get_questions_in_groups($QSG_IDs = '') {
264 264
 
265
-		if ( empty( $QSG_IDs )) {
266
-			EE_Error::add_error( __( 'An error occurred. No Question Group IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
265
+		if (empty($QSG_IDs)) {
266
+			EE_Error::add_error(__('An error occurred. No Question Group IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
267 267
 			return FALSE;
268 268
 		}
269 269
 
270
-		return EE_Registry::instance()->load_model( 'Question' )->get_all( array(
270
+		return EE_Registry::instance()->load_model('Question')->get_all(array(
271 271
 			array(
272
-				'Question_Group.QSG_ID' => array( 'IN', $QSG_IDs ),
272
+				'Question_Group.QSG_ID' => array('IN', $QSG_IDs),
273 273
 				'QST_deleted' => FALSE,
274 274
 				'QST_admin_only' => is_admin()
275 275
 			),
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 	* 		@param		string		$QST_IDs  csv list of $QST IDs
292 292
 	*		@return 		array
293 293
 	*/
294
-	public function get_options_for_question( $QST_IDs ) {
294
+	public function get_options_for_question($QST_IDs) {
295 295
 
296
-		if ( empty( $QST_IDs )) {
297
-			EE_Error::add_error( __( 'An error occurred. No Question IDs were received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
296
+		if (empty($QST_IDs)) {
297
+			EE_Error::add_error(__('An error occurred. No Question IDs were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
298 298
 			return FALSE;
299 299
 		}
300 300
 
301
-		return EE_Registry::instance()->load_model( 'Question_Option' )->get_all( array(
301
+		return EE_Registry::instance()->load_model('Question_Option')->get_all(array(
302 302
 			array(
303
-				'Question.QST_ID' => array( 'IN', $QST_IDs ),
303
+				'Question.QST_ID' => array('IN', $QST_IDs),
304 304
 				'QSO_deleted' => FALSE
305 305
 			),
306 306
 			'order_by' => 'QSO_ID'
@@ -319,45 +319,45 @@  discard block
 block discarded – undo
319 319
 	 * @throws EE_Error
320 320
 	 * @return 	array
321 321
 	 */
322
-	public function assemble_array_of_groups_questions_and_options( EE_Registration $registration, $EVT_ID = 0 ) {
322
+	public function assemble_array_of_groups_questions_and_options(EE_Registration $registration, $EVT_ID = 0) {
323 323
 
324
-		if ( empty( $EVT_ID ) ) {
325
-			throw new EE_Error( __( 'An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso' ) );
324
+		if (empty($EVT_ID)) {
325
+			throw new EE_Error(__('An error occurred. No EVT_ID is included.  Needed to know which question groups to retrieve.', 'event_espresso'));
326 326
 		}
327 327
 
328 328
 		$questions = array();
329 329
 
330 330
 		// get all question groups for event
331
-		$qgs = $this->get_question_groups_for_event( $EVT_ID, $registration );
332
-		if ( !empty( $qgs ) ) {
333
-			foreach ( $qgs as $qg ) {
331
+		$qgs = $this->get_question_groups_for_event($EVT_ID, $registration);
332
+		if ( ! empty($qgs)) {
333
+			foreach ($qgs as $qg) {
334 334
 			 	$qsts = $qg->questions();
335
-			 	$questions[ $qg->ID() ] = $qg->model_field_array();
336
-			 	$questions[ $qg->ID() ]['QSG_questions'] = array();
337
-			 	foreach ( $qsts as $qst ) {
338
-			 		if ( $qst->is_system_question() )
335
+			 	$questions[$qg->ID()] = $qg->model_field_array();
336
+			 	$questions[$qg->ID()]['QSG_questions'] = array();
337
+			 	foreach ($qsts as $qst) {
338
+			 		if ($qst->is_system_question())
339 339
 			 			continue;
340
-			 		$answer = EEM_Answer::instance()->get_one( array( array( 'QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID() ) ) );
340
+			 		$answer = EEM_Answer::instance()->get_one(array(array('QST_ID' => $qst->ID(), 'REG_ID' => $registration->ID())));
341 341
 			 		$answer = $answer instanceof EE_Answer ? $answer : EEM_Answer::instance()->create_default_object();
342 342
 			 		$qst_name = $qstn_id = $qst->ID();
343 343
 			 		$ans_id = $answer->ID();
344
-			 		$qst_name = !empty( $ans_id ) ?  '[' . $qst_name . '][' . $ans_id . ']' : '[' . $qst_name . ']';
344
+			 		$qst_name = ! empty($ans_id) ? '['.$qst_name.']['.$ans_id.']' : '['.$qst_name.']';
345 345
 			 		$input_name = '';
346
-			 		$input_id = sanitize_key( $qst->display_text() );
346
+			 		$input_id = sanitize_key($qst->display_text());
347 347
 			 		$input_class = '';
348 348
 			 		$questions[$qg->ID()]['QSG_questions'][$qst->ID()] = $qst->model_field_array();
349
-		 			$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_name'] = 'qstn' . $input_name . $qst_name;
350
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_id'] = $input_id . '-' . $qstn_id;
351
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_input_class'] = $input_class;
352
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'] = array();
353
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['qst_obj'] = $qst;
354
-					$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['ans_obj'] = $answer;
355
-
356
-					if ( $qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN' ) {
357
-						$QSOs = $qst->options(TRUE,$answer->value());
358
-						if ( is_array( $QSOs ) ) {
359
-							foreach ( $QSOs as $QSO_ID => $QSO ) {
360
-								$questions[ $qg->ID() ]['QSG_questions'][ $qst->ID() ]['QST_options'][ $QSO_ID ] = $QSO->model_field_array();
349
+		 			$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_name'] = 'qstn'.$input_name.$qst_name;
350
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_id'] = $input_id.'-'.$qstn_id;
351
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_input_class'] = $input_class;
352
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'] = array();
353
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['qst_obj'] = $qst;
354
+					$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['ans_obj'] = $answer;
355
+
356
+					if ($qst->type() == 'RADIO_BTN' || $qst->type() == 'CHECKBOX' || $qst->type() == 'DROPDOWN') {
357
+						$QSOs = $qst->options(TRUE, $answer->value());
358
+						if (is_array($QSOs)) {
359
+							foreach ($QSOs as $QSO_ID => $QSO) {
360
+								$questions[$qg->ID()]['QSG_questions'][$qst->ID()]['QST_options'][$QSO_ID] = $QSO->model_field_array();
361 361
 							}
362 362
 						}
363 363
 					}
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 	* 		@param		$QST
382 382
 	*		@return 		string		string
383 383
 	*/
384
-	private function _generate_question_input_name( $QST ) {
384
+	private function _generate_question_input_name($QST) {
385 385
 
386
-		if ( $QST->QST_system ) {
386
+		if ($QST->QST_system) {
387 387
 			$qst_name = $QST->QST_system;
388 388
 /*			switch( $QST->QST_system ) {
389 389
 
@@ -450,20 +450,20 @@  discard block
 block discarded – undo
450 450
 	 * @param bool    $count whether to return the count or not (default FALSE)
451 451
 	 * @return array 	EE_Event objects
452 452
 	 */
453
-	public function get_active_events( $query_params, $count = FALSE ) {
454
-		if ( array_key_exists( 0, $query_params ) ) {
453
+	public function get_active_events($query_params, $count = FALSE) {
454
+		if (array_key_exists(0, $query_params)) {
455 455
 			$where_params = $query_params[0];
456
-			unset( $query_params[0] );
456
+			unset($query_params[0]);
457 457
 		} else {
458 458
 			$where_params = array();
459 459
 		}
460 460
 
461 461
 		//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.
462 462
 		$where_params['status'] = 'publish';
463
-		$where_params['Datetime.DTT_EVT_start'] = array('>',  date('Y-m-d g:i:s', time() ) );
464
-		$where_params['Datetime.DTT_EVT_end'] = array('<', date('Y-m-d g:i:s', time() ) );
463
+		$where_params['Datetime.DTT_EVT_start'] = array('>', date('Y-m-d g:i:s', time()));
464
+		$where_params['Datetime.DTT_EVT_end'] = array('<', date('Y-m-d g:i:s', time()));
465 465
 		$query_params[0] = $where_params;
466
-		$events = $count ? $this->count($query_params, 'EVT_ID') : $this->get_all( $query_params );
466
+		$events = $count ? $this->count($query_params, 'EVT_ID') : $this->get_all($query_params);
467 467
 		return $events;
468 468
 	}
469 469
 
@@ -479,19 +479,19 @@  discard block
 block discarded – undo
479 479
 	 * @param bool    $count whether to return the count or not (default FALSE)
480 480
 	 * @return array               EE_Event objects
481 481
 	 */
482
-	public function get_upcoming_events( $query_params, $count = FALSE ) {
483
-		if ( array_key_exists( 0, $query_params ) ) {
482
+	public function get_upcoming_events($query_params, $count = FALSE) {
483
+		if (array_key_exists(0, $query_params)) {
484 484
 			$where_params = $query_params[0];
485
-			unset( $query_params[0] );
485
+			unset($query_params[0]);
486 486
 		} else {
487 487
 			$where_params = array();
488 488
 		}
489 489
 
490 490
 		//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.
491 491
 		$where_params['status'] = 'publish';
492
-		$where_params['Datetime.DTT_EVT_start'] = array('>', date('Y-m-d g:i:s', time() ) );
492
+		$where_params['Datetime.DTT_EVT_start'] = array('>', date('Y-m-d g:i:s', time()));
493 493
 		$query_params[0] = $where_params;
494
-		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all( $query_params );
494
+		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all($query_params);
495 495
 	}
496 496
 
497 497
 
@@ -503,20 +503,20 @@  discard block
 block discarded – undo
503 503
 	 * @param bool    $count whether to return the count or not (default FALSE)
504 504
 	 * @return array 	EE_Event objects
505 505
 	 */
506
-	public function get_expired_events( $query_params, $count = FALSE ) {
507
-		if ( array_key_exists( 0, $query_params ) ) {
506
+	public function get_expired_events($query_params, $count = FALSE) {
507
+		if (array_key_exists(0, $query_params)) {
508 508
 			$where_params = $query_params[0];
509
-			unset( $query_params[0] );
509
+			unset($query_params[0]);
510 510
 		} else {
511 511
 			$where_params = array();
512 512
 		}
513 513
 
514 514
 		//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.
515
-		if ( isset( $where_params['status'] ) )
516
-			unset( $where_params['status'] );
517
-		$where_params['OR'] = array( 'status' => array( '!=', 'publish' ), 'AND' => array('status' => 'publish', 'Datetime.DTT_EVT_end' => array( '<',  date('Y-m-d g:i:s', time() ) ) ) );
515
+		if (isset($where_params['status']))
516
+			unset($where_params['status']);
517
+		$where_params['OR'] = array('status' => array('!=', 'publish'), 'AND' => array('status' => 'publish', 'Datetime.DTT_EVT_end' => array('<', date('Y-m-d g:i:s', time()))));
518 518
 		$query_params[0] = $where_params;
519
-		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all( $query_params );
519
+		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all($query_params);
520 520
 	}
521 521
 
522 522
 
@@ -527,23 +527,23 @@  discard block
 block discarded – undo
527 527
 	 * @param  boolean $count        whether to return the count or not (default FALSE)
528 528
 	 * @return EE_Event[]            array of EE_Event objects
529 529
 	 */
530
-	public function get_inactive_events( $query_params, $count = FALSE ) {
531
-		if ( array_key_exists( 0, $query_params ) ) {
530
+	public function get_inactive_events($query_params, $count = FALSE) {
531
+		if (array_key_exists(0, $query_params)) {
532 532
 			$where_params = $query_params[0];
533
-			unset( $query_params[0] );
533
+			unset($query_params[0]);
534 534
 		} else {
535 535
 			$where_params = array();
536 536
 		}
537 537
 
538 538
 		//let's add in specific query_params for inactive events.
539
-		if ( isset( $where_params['status'] ) )
540
-			unset( $where_params['status'] );
539
+		if (isset($where_params['status']))
540
+			unset($where_params['status']);
541 541
 
542 542
 		//we check for events that are not published OR are expired.
543 543
 
544
-		$where_params['OR'] = array( 'status' => array( '!=', 'publish' ), 'Datetime.DTT_EVT_end' => array( '<', date('Y-m-d g:i:s', time() ) ) );
544
+		$where_params['OR'] = array('status' => array('!=', 'publish'), 'Datetime.DTT_EVT_end' => array('<', date('Y-m-d g:i:s', time())));
545 545
 		$query_params[0] = $where_params;
546
-		return $count ? $this->count( $query_params, 'EVT_ID' ) : $this->get_all( $query_params );
546
+		return $count ? $this->count($query_params, 'EVT_ID') : $this->get_all($query_params);
547 547
 	}
548 548
 
549 549
 
@@ -551,13 +551,13 @@  discard block
 block discarded – undo
551 551
 	 * 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.
552 552
 	 * See parent for param descriptions
553 553
 	 */
554
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
554
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
555 555
 
556
-		if ( $relationName == 'Price' ) {
556
+		if ($relationName == 'Price') {
557 557
 			//let's get the PRC object for the given ID to make sure that we aren't dealing with a default
558 558
 			$prc_chk = $this->get_related_model_obj($relationName)->ensure_is_obj($other_model_id_or_obj);
559 559
 			//if EVT_ID = 0, then this is a default
560
-			if ( $prc_chk->get('EVT_ID') == 0 ) {
560
+			if ($prc_chk->get('EVT_ID') == 0) {
561 561
 				//let's set the prc_id as 0 so we force an insert on the add_relation_to carried out by relation
562 562
 				$prc_chk->set('PRC_ID', 0);
563 563
 			}
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 		}
568 568
 
569 569
 		//otherwise carry on as normal
570
-		return parent::add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query);
570
+		return parent::add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query);
571 571
 	}
572 572
 
573 573
 
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.
core/db_models/EEM_Transaction.model.php 2 patches
Spacing   +33 added lines, -33 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
  * Transaction Model
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
 	 * 		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)
69 69
 	 *	@return EEM_Transaction
70 70
 	 */
71
-	protected function __construct( $timezone ) {
72
-		$this->singular_item = __('Transaction','event_espresso');
73
-		$this->plural_item = __('Transactions','event_espresso');
71
+	protected function __construct($timezone) {
72
+		$this->singular_item = __('Transaction', 'event_espresso');
73
+		$this->plural_item = __('Transactions', 'event_espresso');
74 74
 
75 75
 		$this->_tables = array(
76
-			'Transaction'=>new EE_Primary_Table('esp_transaction','TXN_ID')
76
+			'Transaction'=>new EE_Primary_Table('esp_transaction', 'TXN_ID')
77 77
 		);
78 78
 		$this->_fields = array(
79 79
 			'Transaction'=>array(
80
-				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID','event_espresso')),
81
-				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created','event_espresso'), false, current_time('timestamp'), $timezone ),
82
-				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction','event_espresso'), false, 0),
83
-				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date','event_espresso'), false, 0),
84
-				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID','event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
85
-				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data','event_espresso'), true, ''),
86
-				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt','event_espresso'), true, ''),
80
+				'TXN_ID'=>new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
81
+				'TXN_timestamp'=>new EE_Datetime_Field('TXN_timestamp', __('date when transaction was created', 'event_espresso'), false, current_time('timestamp'), $timezone),
82
+				'TXN_total'=>new EE_Money_Field('TXN_total', __('Total value of Transaction', 'event_espresso'), false, 0),
83
+				'TXN_paid'=>new EE_Money_Field('TXN_paid', __('Amount paid towards transaction to date', 'event_espresso'), false, 0),
84
+				'STS_ID'=>new EE_Foreign_Key_String_Field('STS_ID', __('Status ID', 'event_espresso'), false, EEM_Transaction::failed_status_code, 'Status'),
85
+				'TXN_session_data'=>new EE_Serialized_Text_Field('TXN_session_data', __('Serialized session data', 'event_espresso'), true, ''),
86
+				'TXN_hash_salt'=>new EE_Plain_Text_Field('TXN_hash_salt', __('Transaction Hash Salt', 'event_espresso'), true, ''),
87 87
 				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __("Last Used Payment Method", 'event_espresso'), true, NULL, 'Payment_Method'),
88
-				'TXN_reg_steps' => new EE_Serialized_Text_Field( 'TXN_reg_steps', __( 'Registration Steps', 'event_espresso' ), FALSE, array() ),
88
+				'TXN_reg_steps' => new EE_Serialized_Text_Field('TXN_reg_steps', __('Registration Steps', 'event_espresso'), FALSE, array()),
89 89
 			)
90 90
 		);
91 91
 		$this->_model_relations = array(
92 92
 			'Registration'=>new EE_Has_Many_Relation(),
93 93
 			'Payment'=>new EE_Has_Many_Relation(),
94 94
 			'Status'=>new EE_Belongs_To_Relation(),
95
-			'Line_Item'=>new EE_Has_Many_Relation(false),//you can delete a transaction without needing to delete its line items
95
+			'Line_Item'=>new EE_Has_Many_Relation(false), //you can delete a transaction without needing to delete its line items
96 96
 			'Payment_Method'=>new EE_Belongs_To_Relation(),
97 97
 		);
98 98
 		$this->_model_chain_to_wp_user = 'Registration.Event';
99
-		parent::__construct( $timezone );
99
+		parent::__construct($timezone);
100 100
 
101 101
 	}
102 102
 
@@ -107,19 +107,19 @@  discard block
 block discarded – undo
107 107
 	 * @param string $period
108 108
 	 * @return \stdClass[]
109 109
 	 */
110
-	public function get_revenue_per_day_report( $period = '-1 month' ) {
110
+	public function get_revenue_per_day_report($period = '-1 month') {
111 111
 
112
-		$sql_date = date("Y-m-d H:i:s", strtotime($period) );
112
+		$sql_date = date("Y-m-d H:i:s", strtotime($period));
113 113
 		$results = $this->_get_all_wpdb_results(
114 114
 			array(
115 115
 				array(
116 116
 					'TXN_timestamp' => array('>=', $sql_date)),
117 117
 					'group_by' => 'txnDate',
118
-					'order_by' => array('TXN_timestamp' => 'DESC' )
118
+					'order_by' => array('TXN_timestamp' => 'DESC')
119 119
 					),
120 120
 				OBJECT,
121 121
 				array(
122
-					'txnDate' => array('DATE(Transaction.TXN_timestamp)','%s'),
122
+					'txnDate' => array('DATE(Transaction.TXN_timestamp)', '%s'),
123 123
 					'revenue' => array('SUM(Transaction.TXN_paid)', '%d')
124 124
 					));
125 125
 		return $results;
@@ -135,21 +135,21 @@  discard block
 block discarded – undo
135 135
 	 * @throws \EE_Error
136 136
 	 * @return mixed
137 137
 	 */
138
-	public function get_revenue_per_event_report( $period = 'month' ) {
138
+	public function get_revenue_per_event_report($period = 'month') {
139 139
 		global $wpdb;
140
-		$date_mod = strtotime( '-1 ' . $period );
140
+		$date_mod = strtotime('-1 '.$period);
141 141
 
142 142
 		$SQL = 'SELECT post_title as event_name, SUM(TXN_paid) AS revenue';
143
-		$SQL .= ' FROM ' . $this->_get_main_table()->get_table_name() . ' txn';
144
-		$SQL .= ' LEFT JOIN ' . $wpdb->prefix . 'esp_registration reg ON reg.TXN_ID = txn.TXN_ID';
145
-		$SQL .= ' LEFT JOIN ' . $wpdb->posts . ' evt ON evt.ID = reg.EVT_ID';
143
+		$SQL .= ' FROM '.$this->_get_main_table()->get_table_name().' txn';
144
+		$SQL .= ' LEFT JOIN '.$wpdb->prefix.'esp_registration reg ON reg.TXN_ID = txn.TXN_ID';
145
+		$SQL .= ' LEFT JOIN '.$wpdb->posts.' evt ON evt.ID = reg.EVT_ID';
146 146
 		$SQL .= ' WHERE REG_count = 1';
147 147
 		$SQL .= ' AND REG_date >= %d';
148 148
 		$SQL .= ' GROUP BY event_name';
149 149
 		$SQL .= ' ORDER BY event_name';
150 150
 		$SQL .= ' LIMIT 0, 24';
151 151
 
152
-		return $this->_do_wpdb_query( 'get_results', array(  $wpdb->prepare( $SQL, $date_mod ) ) );
152
+		return $this->_do_wpdb_query('get_results', array($wpdb->prepare($SQL, $date_mod)));
153 153
 
154 154
 	}
155 155
 
@@ -165,10 +165,10 @@  discard block
 block discarded – undo
165 165
 	 * @param string $reg_url_link
166 166
 	 * @return EE_Transaction
167 167
 	 */
168
-	public function get_transaction_from_reg_url_link( $reg_url_link = '' ){
169
-		return $this->get_one( array(
168
+	public function get_transaction_from_reg_url_link($reg_url_link = '') {
169
+		return $this->get_one(array(
170 170
 			array(
171
-				'Registration.REG_url_link' => ! empty( $reg_url_link ) ? $reg_url_link : EE_Registry::instance()->REQ->get( 'e_reg_url_link', '' )
171
+				'Registration.REG_url_link' => ! empty($reg_url_link) ? $reg_url_link : EE_Registry::instance()->REQ->get('e_reg_url_link', '')
172 172
 			)
173 173
 		));
174 174
 	}
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @param boolean $save_txn whether or not to save the transaction during this function call
189 189
 	 * @return boolean
190 190
 	 */
191
-	public function update_based_on_payments( $transaction_obj_or_id, $save_txn = TRUE ){
191
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = TRUE) {
192 192
 		EE_Error::doing_it_wrong(
193
-			__CLASS__ . '::' . __FUNCTION__,
194
-			sprintf( __( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()' ),
193
+			__CLASS__.'::'.__FUNCTION__,
194
+			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'), 'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'),
195 195
 			'4.6.0'
196 196
 		);
197 197
 		/** @type EE_Transaction_Processor $transaction_processor */
198
-		$transaction_processor = EE_Registry::instance()->load_class( 'Transaction_Processor' );
199
-		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment( $this->ensure_is_obj( $transaction_obj_or_id ));
198
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
199
+		return  $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment($this->ensure_is_obj($transaction_obj_or_id));
200 200
 	}
201 201
 
202 202
 
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
 require_once ( EE_MODELS . 'EEM_Base.model.php' );
3 5
 /**
4 6
  *
Please login to merge, or discard this patch.
core/db_models/fields/EE_Datetime_Field.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -550,7 +550,7 @@
 block discarded – undo
550 550
 				}
551 551
 			}
552 552
 		}
553
-        		return FALSE;
553
+				return FALSE;
554 554
 	}
555 555
 
556 556
 
Please login to merge, or discard this patch.
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -59,19 +59,19 @@  discard block
 block discarded – undo
59 59
 	 * @param null $pretty_date_format
60 60
 	 * @param null $pretty_time_format
61 61
 	 */
62
-	public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone = NULL, $date_format = NULL, $time_format = NULL, $pretty_date_format = NULL, $pretty_time_format = NULL ){
62
+	public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone = NULL, $date_format = NULL, $time_format = NULL, $pretty_date_format = NULL, $pretty_time_format = NULL) {
63 63
 
64 64
 		parent::__construct($table_column, $nice_name, $nullable, $default_value);
65 65
 		$this->_date_format = empty($date_format) ? get_option('date_format') : $date_format;
66
-		$this->_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime( $this->_date_format );
66
+		$this->_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime($this->_date_format);
67 67
 		$this->_time_format = empty($time_format) ? get_option('time_format') : $time_format;
68 68
 
69
-		$this->set_timezone( $timezone );
69
+		$this->set_timezone($timezone);
70 70
 
71 71
 
72 72
 		$this->_pretty_date_format = empty($pretty_date_format) ? get_option('date_format') : $pretty_date_format;
73
-		$this->_pretty_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime( $this->_pretty_date_format );
74
-		$this->_pretty_time_format = empty( $pretty_time_format ) ? get_option('time_format') : $pretty_time_format;
73
+		$this->_pretty_date_format = EE_Base_Class::fix_date_format_for_use_with_strtotime($this->_pretty_date_format);
74
+		$this->_pretty_time_format = empty($pretty_time_format) ? get_option('time_format') : $pretty_time_format;
75 75
 	}
76 76
 
77 77
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	 * @return DateTimeZone|null
90 90
 	 */
91 91
 	public static function get_UTC_DateTimeZone() {
92
-		return EE_Datetime_Field::$_UTC_DateTimeZone instanceof DateTimeZone ? EE_Datetime_Field::$_UTC_DateTimeZone : new DateTimeZone( 'UTC' );
92
+		return EE_Datetime_Field::$_UTC_DateTimeZone instanceof DateTimeZone ? EE_Datetime_Field::$_UTC_DateTimeZone : new DateTimeZone('UTC');
93 93
 	}
94 94
 
95 95
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	 * @return int                                           unix timestamp (utc)
101 101
 	 */
102 102
 	public function prepare_for_set($value_inputted_for_field_on_model_object) {
103
-		return $this->_convert_to_utc_unix_timestamp( $value_inputted_for_field_on_model_object);
103
+		return $this->_convert_to_utc_unix_timestamp($value_inputted_for_field_on_model_object);
104 104
 	}
105 105
 
106 106
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 	 * @param bool $pretty If we're returning the pretty formats or standard format string.
117 117
 	 * @return string    The final assembled format string.
118 118
 	 */
119
-	private function _get_date_time_output( $pretty = FALSE ) {
119
+	private function _get_date_time_output($pretty = FALSE) {
120 120
 
121
-		switch ( $this->_date_time_output ) {
121
+		switch ($this->_date_time_output) {
122 122
 			case 'time' :
123 123
 				return $pretty ? $this->_pretty_time_format : $this->_time_format;
124 124
 				break;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				break;
129 129
 
130 130
 			default :
131
-				return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format;
131
+				return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format;
132 132
 		}
133 133
 	}
134 134
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 	 * @param string $what acceptable values are 'time' or 'date'.  Any other value will be set but will always result in both 'date' and 'time' being returned.
143 143
 	 * @return void
144 144
 	 */
145
-	public function set_date_time_output( $what = NULL ) {
145
+	public function set_date_time_output($what = NULL) {
146 146
 		$this->_date_time_output = $what;
147 147
 	}
148 148
 
@@ -158,23 +158,23 @@  discard block
 block discarded – undo
158 158
 	 * @param string $timezone A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php
159 159
 	 * @return void
160 160
 	 */
161
-	public function set_timezone( $timezone ) {
162
-		if( $timezone === NULL && $this->_timezone != NULL){
161
+	public function set_timezone($timezone) {
162
+		if ($timezone === NULL && $this->_timezone != NULL) {
163 163
 			//leave the timezone AS-IS if we already have one and
164 164
 			//the function arg didn't provide one
165 165
 			return;
166 166
 		}
167
-		$this->_timezone = empty( $timezone ) ? get_option('timezone_string') : $timezone;
167
+		$this->_timezone = empty($timezone) ? get_option('timezone_string') : $timezone;
168 168
 
169 169
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
170
-		if ( empty( $this->_timezone ) ) {
170
+		if (empty($this->_timezone)) {
171 171
 			//let's get a the WordPress UTC offset
172 172
 			$offset = get_option('gmt_offset');
173 173
 			$this->_blog_offset = $offset;
174
-			$this->_timezone = self::timezone_convert_to_string_from_offset( $offset );
174
+			$this->_timezone = self::timezone_convert_to_string_from_offset($offset);
175 175
 		}
176 176
 
177
-		self::validate_timezone( $this->_timezone ); //just running validation on the timezone.
177
+		self::validate_timezone($this->_timezone); //just running validation on the timezone.
178 178
 	}
179 179
 
180 180
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @param string $format a new date format (corresponding to formats accepted by PHP date() function)
199 199
 	 * @return void
200 200
 	 */
201
-	public function set_date_format( $format ) {
201
+	public function set_date_format($format) {
202 202
 		$this->_date_format = $format;
203 203
 	}
204 204
 
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 	 * @param string $format a new time format (corresponding to formats accepted by PHP date() function)
213 213
 	 * @return void
214 214
 	 */
215
-	public function set_time_format( $format ) {
215
+	public function set_time_format($format) {
216 216
 		$this->_time_format = $format;
217 217
 	}
218 218
 
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function)
228 228
 	 * @return void
229 229
 	 */
230
-	public function set_pretty_date_format( $format ) {
230
+	public function set_pretty_date_format($format) {
231 231
 		$this->_pretty_date_format = $format;
232 232
 	}
233 233
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function)
245 245
 	 * @return void
246 246
 	 */
247
-	public function set_pretty_time_format( $format ) {
247
+	public function set_pretty_time_format($format) {
248 248
 		$this->_pretty_time_format = $format;
249 249
 	}
250 250
 
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
 	 * @throws EE_Error
258 258
 	 * @return int updated timestamp
259 259
 	 */
260
-	public function prepare_for_set_with_new_time($time_to_set_string, $current_datetime_value ){
261
-		$this->_set_date_obj( date( $this->_date_format . ' ' . $this->_time_format, $current_datetime_value), 'UTC' );
262
-		if ( ! $this->_date instanceof DateTime  && ! $this->_nullable ) {
263
-			throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
260
+	public function prepare_for_set_with_new_time($time_to_set_string, $current_datetime_value) {
261
+		$this->_set_date_obj(date($this->_date_format.' '.$this->_time_format, $current_datetime_value), 'UTC');
262
+		if ( ! $this->_date instanceof DateTime && ! $this->_nullable) {
263
+			throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso'));
264 264
 		}
265
-		return $this->_prepare_for_set_new( $time_to_set_string, TRUE );
265
+		return $this->_prepare_for_set_new($time_to_set_string, TRUE);
266 266
 	}
267 267
 
268 268
 
@@ -274,12 +274,12 @@  discard block
 block discarded – undo
274 274
 	 * @throws EE_Error
275 275
 	 * @return int updated timestamp
276 276
 	 */
277
-	public function prepare_for_set_with_new_date($date_to_set_string, $current_datetime_value ){
278
-		$this->_set_date_obj( date( $this->_date_format  . ' ' . $this->_time_format, $current_datetime_value ), 'UTC' );
279
-		if ( ! $this->_date instanceof DateTime && ! $this->_nullable ) {
280
-			throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
277
+	public function prepare_for_set_with_new_date($date_to_set_string, $current_datetime_value) {
278
+		$this->_set_date_obj(date($this->_date_format.' '.$this->_time_format, $current_datetime_value), 'UTC');
279
+		if ( ! $this->_date instanceof DateTime && ! $this->_nullable) {
280
+			throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso'));
281 281
 		}
282
-		return $this->_prepare_for_set_new( $date_to_set_string );
282
+		return $this->_prepare_for_set_new($date_to_set_string);
283 283
 	}
284 284
 
285 285
 
@@ -292,11 +292,11 @@  discard block
 block discarded – undo
292 292
 	 * @param  int    $datetime_value This will always be a unix timestamp in UTC because that's what the internal data type of the date time property is.
293 293
 	 * @return string                formatted date time for given timezone
294 294
 	 */
295
-	public function prepare_for_get( $datetime_value ) {
295
+	public function prepare_for_get($datetime_value) {
296 296
 
297 297
 		$format_string = $this->_get_date_time_output();
298 298
 		//send this to our formatter to return localized time for the timezone
299
-		return $this->_convert_to_timezone_from_utc_unix_timestamp( $datetime_value, $format_string );
299
+		return $this->_convert_to_timezone_from_utc_unix_timestamp($datetime_value, $format_string);
300 300
 	}
301 301
 
302 302
 
@@ -310,19 +310,19 @@  discard block
 block discarded – undo
310 310
 	 * @internal param mixed $value_on_field_to_be_outputted
311 311
 	 * @return mixed
312 312
 	 */
313
-	public function prepare_for_pretty_echoing( $datetime_value, $schema = null ) {
314
-		if( $this->_display_timezone() ) {
315
-			if( $schema == 'no_html' ){
316
-				$timezone_string = '(' . self::get_timezone_abbrev( $this->_timezone ) . ')';
317
-			}else{
318
-				$timezone_string = '<span class="ee_dtt_timezone_string">(' . self::get_timezone_abbrev($this->_timezone) . ')</span>';
313
+	public function prepare_for_pretty_echoing($datetime_value, $schema = null) {
314
+		if ($this->_display_timezone()) {
315
+			if ($schema == 'no_html') {
316
+				$timezone_string = '('.self::get_timezone_abbrev($this->_timezone).')';
317
+			} else {
318
+				$timezone_string = '<span class="ee_dtt_timezone_string">('.self::get_timezone_abbrev($this->_timezone).')</span>';
319 319
 			}
320 320
 		} else {
321 321
 			$timezone_string = '';
322 322
 		}
323 323
 
324
-		$format_string = $this->_get_date_time_output( TRUE );
325
-		return $this->_convert_to_timezone_from_utc_unix_timestamp( $datetime_value, $format_string ) . $timezone_string;
324
+		$format_string = $this->_get_date_time_output(TRUE);
325
+		return $this->_convert_to_timezone_from_utc_unix_timestamp($datetime_value, $format_string).$timezone_string;
326 326
 	}
327 327
 
328 328
 
@@ -333,8 +333,8 @@  discard block
 block discarded – undo
333 333
 	 * @param  int $datetime_value unix timestamp in UTC
334 334
 	 * @return string                mysql timestamp in UTC
335 335
 	 */
336
-	public function prepare_for_use_in_db( $datetime_value ) {
337
-		return $this->_nullable && empty( $datetime_value) ? NULL : date( "Y-m-d H:i:s", $datetime_value );
336
+	public function prepare_for_use_in_db($datetime_value) {
337
+		return $this->_nullable && empty($datetime_value) ? NULL : date("Y-m-d H:i:s", $datetime_value);
338 338
 	}
339 339
 
340 340
 
@@ -346,8 +346,8 @@  discard block
 block discarded – undo
346 346
 	 * @param  string $datetime_value mysql timestamp in UTC
347 347
 	 * @return int                 UnixTime in UTC
348 348
 	 */
349
-	public function prepare_for_set_from_db( $datetime_value ) {
350
-		return $this->_nullable && empty( $datetime_value ) ? NULL : strtotime( $datetime_value );
349
+	public function prepare_for_set_from_db($datetime_value) {
350
+		return $this->_nullable && empty($datetime_value) ? NULL : strtotime($datetime_value);
351 351
 	}
352 352
 
353 353
 
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 	 * @throws EE_Error
360 360
 	 * @return string           final converted date-time-zone.
361 361
 	 */
362
-	private function _convert_to_timezone_from_utc_unix_timestamp( $datetime_value, $format ) {
363
-		if ( $this->_nullable && empty( $datetime_value )) {
362
+	private function _convert_to_timezone_from_utc_unix_timestamp($datetime_value, $format) {
363
+		if ($this->_nullable && empty($datetime_value)) {
364 364
 			return NULL;
365 365
 		}
366
-		$datetime = date( 'Y-m-d H:i:s', (int)$datetime_value );
367
-		$this->_set_date_obj( $datetime, 'UTC' );
368
-		if ( ! $this->_date instanceof DateTime ) {
369
-			throw new EE_Error( sprintf( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used on %s', 'event_espresso' ) , $this->get_model_name() ) );
366
+		$datetime = date('Y-m-d H:i:s', (int) $datetime_value);
367
+		$this->_set_date_obj($datetime, 'UTC');
368
+		if ( ! $this->_date instanceof DateTime) {
369
+			throw new EE_Error(sprintf(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used on %s', 'event_espresso'), $this->get_model_name()));
370 370
 		}
371
-		$this->_date->setTimezone( new DateTimeZone( $this->_timezone ) );
372
-		return $this->_date->format( $format );
371
+		$this->_date->setTimezone(new DateTimeZone($this->_timezone));
372
+		return $this->_date->format($format);
373 373
 
374 374
 	}
375 375
 
@@ -388,22 +388,22 @@  discard block
 block discarded – undo
388 388
 	 * @param  boolean $is_time            If this is a time adjustment set this boolean flag to true, otherwise it is a date adjustment
389 389
 	 * @return int                         UTC UnixTimestamp
390 390
 	 */
391
-	private function _prepare_for_set_new( $datetime_adjustment, $is_time = FALSE ) {
392
-		if ( $this->_nullable && empty( $datetime_adjustment ) ) {
391
+	private function _prepare_for_set_new($datetime_adjustment, $is_time = FALSE) {
392
+		if ($this->_nullable && empty($datetime_adjustment)) {
393 393
 			return NULL;
394 394
 		}
395 395
 		//first let's parse the incoming string
396
-		$parsed = date_parse( $datetime_adjustment );
396
+		$parsed = date_parse($datetime_adjustment);
397 397
 		//set the timezone to the incoming timezone for the current date_object
398
-		$this->_date->setTimezone( new DateTimeZone( $this->_timezone ) );
398
+		$this->_date->setTimezone(new DateTimeZone($this->_timezone));
399 399
 		//let's adjust the time or date depending on our $is_time boolean
400
-		if ( $is_time ) {
401
-			$this->_date->setTime( $parsed['hour'], $parsed['minute'] );
400
+		if ($is_time) {
401
+			$this->_date->setTime($parsed['hour'], $parsed['minute']);
402 402
 		} else {
403
-			$this->_date->setDate( $parsed['year'], $parsed['month'], $parsed['day'] );
403
+			$this->_date->setDate($parsed['year'], $parsed['month'], $parsed['day']);
404 404
 		}
405 405
 		//return to UTC time
406
-		$this->_date->setTimezone( EE_Datetime_Field::get_UTC_DateTimeZone() );
406
+		$this->_date->setTimezone(EE_Datetime_Field::get_UTC_DateTimeZone());
407 407
 		//return unix timestamp
408 408
 		return $this->_date->format('U');
409 409
 	}
@@ -418,10 +418,10 @@  discard block
 block discarded – undo
418 418
 	 * @param  string|int $datetime This can be either an integer timestamp (in which case this method will convert from int to string first to make sure we get the right timezone setup )
419 419
 	 * @return string 		unix timestamp for utc
420 420
 	 */
421
-	private function _convert_to_utc_unix_timestamp( $datetime ) {
422
-		if ( $this->_nullable && empty( $datetime ) )
421
+	private function _convert_to_utc_unix_timestamp($datetime) {
422
+		if ($this->_nullable && empty($datetime))
423 423
 			return NULL;
424
-		$timestamp = is_numeric( $datetime ) ? $this->_convert_from_numeric_value_to_utc_unix_timestamp( $datetime ) : $this->_convert_from_string_value_to_utc_unix_timestamp( $datetime );
424
+		$timestamp = is_numeric($datetime) ? $this->_convert_from_numeric_value_to_utc_unix_timestamp($datetime) : $this->_convert_from_string_value_to_utc_unix_timestamp($datetime);
425 425
 		return $timestamp;
426 426
 	}
427 427
 
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
 	 * @return bool|int|string
433 433
 	 * @throws EE_Error
434 434
 	 */
435
-	private function _convert_from_numeric_value_to_utc_unix_timestamp( $datetime ) {
436
-		$datetime = date( 'Y-m-d H:i:s', (int) $datetime);
435
+	private function _convert_from_numeric_value_to_utc_unix_timestamp($datetime) {
436
+		$datetime = date('Y-m-d H:i:s', (int) $datetime);
437 437
 
438
-		date_default_timezone_set( $this->_timezone );
438
+		date_default_timezone_set($this->_timezone);
439 439
 		$timestamp = strtotime($datetime);
440 440
 
441 441
 		//if we don't have a datetime at this point then something has gone wrong
442
-		if ( $timestamp === NULL || $timestamp === FALSE) {
443
-			throw new EE_Error( sprintf( __('Something went wrong with setting the date/time.  Likely, either there is an invalid timezone string or invalid timestamp being used. Datetime passed in: %s producted timestamp: %s', 'event_espresso' ), $datetime, $timestamp )  );
442
+		if ($timestamp === NULL || $timestamp === FALSE) {
443
+			throw new EE_Error(sprintf(__('Something went wrong with setting the date/time.  Likely, either there is an invalid timezone string or invalid timestamp being used. Datetime passed in: %s producted timestamp: %s', 'event_espresso'), $datetime, $timestamp));
444 444
 		}
445 445
 
446 446
 		//return to default for PHP
@@ -457,15 +457,15 @@  discard block
 block discarded – undo
457 457
 	 * @return string
458 458
 	 * @throws EE_Error
459 459
 	 */
460
-	private function _convert_from_string_value_to_utc_unix_timestamp( $datetime ) {
460
+	private function _convert_from_string_value_to_utc_unix_timestamp($datetime) {
461 461
 		//create a new datetime object using the given string and timezone
462
-		$this->_set_date_obj( $datetime, $this->_timezone );
462
+		$this->_set_date_obj($datetime, $this->_timezone);
463 463
 
464
-		if ( ! $this->_date instanceof DateTime && ! $this->_nullable ) {
465
-			throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
464
+		if ( ! $this->_date instanceof DateTime && ! $this->_nullable) {
465
+			throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso'));
466 466
 		}
467 467
 
468
-		$this->_date->setTimezone( EE_Datetime_Field::get_UTC_DateTimeZone() );
468
+		$this->_date->setTimezone(EE_Datetime_Field::get_UTC_DateTimeZone());
469 469
 		return $this->_date->format('U');
470 470
 
471 471
 	}
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
 	 * @throws EE_Error
482 482
 	 * @return boolean    Return True if Valid, False if Invalid
483 483
 	 */
484
-	public static function validate_timezone( $timezone_string ) {
484
+	public static function validate_timezone($timezone_string) {
485 485
 		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
486 486
 		try {
487
-			new DateTimeZone( $timezone_string );
488
-		} catch ( Exception $e ) {
489
-			throw new EE_Error( sprintf(
490
-				__( 'The timezone given (%s), is invalid, please check with %sthis list%s for what valid timezones can be used', 'event_espresso' ),
487
+			new DateTimeZone($timezone_string);
488
+		} catch (Exception $e) {
489
+			throw new EE_Error(sprintf(
490
+				__('The timezone given (%s), is invalid, please check with %sthis list%s for what valid timezones can be used', 'event_espresso'),
491 491
 				$timezone_string,
492 492
 				'<a href="http://www.php.net/manual/en/timezones.php">',
493 493
 				'</a>'
@@ -506,13 +506,13 @@  discard block
 block discarded – undo
506 506
 	 * @param  string $offset GMT offset
507 507
 	 * @return string         timezone_string (valid for DateTimeZone)
508 508
 	 */
509
-	public static function timezone_convert_to_string_from_offset( $offset ) {
509
+	public static function timezone_convert_to_string_from_offset($offset) {
510 510
 		$offset *= 3600; // convert hour offset to seconds
511 511
 		//make sure $offset is int (cause if incoming was int then converted to float);
512 512
 		$offset = (int) $offset;
513 513
 
514 514
 		//account for WP offsets that aren't valid UTC
515
-		switch ( $offset ) {
515
+		switch ($offset) {
516 516
 			case -1800 :
517 517
 				$offset = -3600;
518 518
 				break;
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 		}
544 544
 
545 545
 		$abbreviations = timezone_abbreviations_list();
546
-		foreach ( $abbreviations as $abbreviation ) {
547
-			foreach ( $abbreviation as $city ) {
548
-				if ( $city['offset'] === $offset && $city['dst'] === FALSE ) {
546
+		foreach ($abbreviations as $abbreviation) {
547
+			foreach ($abbreviation as $city) {
548
+				if ($city['offset'] === $offset && $city['dst'] === FALSE) {
549 549
 					return $city['timezone_id'];
550 550
 				}
551 551
 			}
@@ -561,18 +561,18 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $tz valid timezone string
562 562
 	 * @return int     if conversion can happen then we return the offset, if not then we return FALSE (or EE_Error)
563 563
 	 */
564
-	public static function timezone_convert_to_offset_from_string( $tz ) {
564
+	public static function timezone_convert_to_offset_from_string($tz) {
565 565
 		$abbreviations = timezone_abbreviations_list();
566 566
 		$offset = NULL;
567
-		foreach ( $abbreviations as $abbreviation ) {
568
-			foreach ( $abbreviation as $city ) {
569
-				if ( $city['timezone_id'] == $tz ) {
567
+		foreach ($abbreviations as $abbreviation) {
568
+			foreach ($abbreviation as $city) {
569
+				if ($city['timezone_id'] == $tz) {
570 570
 					$offset = $city['offset'];
571 571
 				}
572 572
 			}
573 573
 		}
574 574
 		//$offset will be in seconds so let's convert to hours and make sure its an int
575
-		return ! empty( $offset) ? (int)( $offset / 3600 ) : 0;
575
+		return ! empty($offset) ? (int) ($offset / 3600) : 0;
576 576
 	}
577 577
 
578 578
 
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 
589 589
 		//first let's do a comparison of timezone strings.  If they match then we can get out without any further calculations
590 590
 		$blog_string = get_option('timezone_string');
591
-		if ( $blog_string == $this->_timezone )
591
+		if ($blog_string == $this->_timezone)
592 592
 			return FALSE;
593 593
 
594 594
 		//now we need to calc the offset for the timezone string so we can compare with the blog offset.
595
-		$this_offset = self::timezone_convert_to_offset_from_string( $this->_timezone );
596
-		$blog_offset = !empty( $this->_blog_offset ) ? $this->_blog_offset : self::timezone_convert_to_offset_from_string( $blog_string );
595
+		$this_offset = self::timezone_convert_to_offset_from_string($this->_timezone);
596
+		$blog_offset = ! empty($this->_blog_offset) ? $this->_blog_offset : self::timezone_convert_to_offset_from_string($blog_string);
597 597
 
598 598
 		//now compare
599
-		if ( $blog_offset === $this_offset )
599
+		if ($blog_offset === $this_offset)
600 600
 			return FALSE;
601 601
 
602 602
 		return TRUE;
@@ -612,32 +612,32 @@  discard block
 block discarded – undo
612 612
 	 * @throws Exception
613 613
 	 * @return void
614 614
 	 */
615
-	private function _set_date_obj( $date_string, $timezone ) {
616
-		if ( $this->_nullable && empty( $date_string ) ) {
615
+	private function _set_date_obj($date_string, $timezone) {
616
+		if ($this->_nullable && empty($date_string)) {
617 617
 			$this->_date = NULL;
618 618
 			return;
619 619
 		}
620 620
 		try {
621 621
 			//start off assuming it's a wonky excel format
622
-			if ( version_compare( PHP_VERSION, '5.3.0' ) >= 0 ) {
622
+			if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
623 623
 				// maybe it's the Microsoft excel format '16/08/2013 8:58' ?
624
-				$this->_date = DateTime::createFromFormat( 'd/m/Y H:i', $date_string, new DateTimeZone( $timezone ));
624
+				$this->_date = DateTime::createFromFormat('d/m/Y H:i', $date_string, new DateTimeZone($timezone));
625 625
 			} else {
626 626
 				//change 'd/m/Y H:i'  to 'd-m-Y H:i'  because of how strtotime() interprets date formats. see: http://www.php.net/manual/en/datetime.formats.date.php
627
-				$this->_date = new DateTime( date( 'd-m-Y H:i', strtotime( $date_string )), new DateTimeZone( $timezone ));
627
+				$this->_date = new DateTime(date('d-m-Y H:i', strtotime($date_string)), new DateTimeZone($timezone));
628 628
 			}
629
-		} catch( Exception $e ) {}
629
+		} catch (Exception $e) {}
630 630
 
631
-		if( ! $this->_date ){
631
+		if ( ! $this->_date) {
632 632
 			try {
633
-				$this->_date = new DateTime( $date_string, new DateTimeZone( $timezone ));
634
-			} catch( Exception $e ) {
633
+				$this->_date = new DateTime($date_string, new DateTimeZone($timezone));
634
+			} catch (Exception $e) {
635 635
 				// because DateTime chokes on some formats, check if strtotime fails, and throw error regarding bad format
636
-				if ( strtotime( $date_string ) == 0 ) {
637
-					throw new Exception( sprintf( __('The following date time \'%s\' can not be parsed by PHP due to its formatting.%sYou may need to choose a more standard date time format. Please check your WordPress Settings.', 'event_espresso' ), $date_string, '<br />' ));
636
+				if (strtotime($date_string) == 0) {
637
+					throw new Exception(sprintf(__('The following date time \'%s\' can not be parsed by PHP due to its formatting.%sYou may need to choose a more standard date time format. Please check your WordPress Settings.', 'event_espresso'), $date_string, '<br />'));
638 638
 				} else {
639 639
 					//ok give up, but don't throw an error
640
-					$this->_date = new DateTime( NULL, new DateTimeZone( $timezone ));
640
+					$this->_date = new DateTime(NULL, new DateTimeZone($timezone));
641 641
 				}
642 642
 			}
643 643
 		}
@@ -651,9 +651,9 @@  discard block
 block discarded – undo
651 651
 	 * @param  string $timezone Valid timezone String
652 652
 	 * @return string           abbreviation
653 653
 	 */
654
-	public static function get_timezone_abbrev( $timezone ) {
654
+	public static function get_timezone_abbrev($timezone) {
655 655
 		$dateTime = new DateTime();
656
-		$dateTime->setTimeZone( new DateTimeZone($timezone) );
656
+		$dateTime->setTimeZone(new DateTimeZone($timezone));
657 657
 		return $dateTime->format('T');
658 658
 	}
659 659
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -7 removed lines patch added patch discarded remove patch
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		if( $this->_display_timezone() ) {
315 315
 			if( $schema == 'no_html' ){
316 316
 				$timezone_string = '(' . self::get_timezone_abbrev( $this->_timezone ) . ')';
317
-			}else{
317
+			} else{
318 318
 				$timezone_string = '<span class="ee_dtt_timezone_string">(' . self::get_timezone_abbrev($this->_timezone) . ')</span>';
319 319
 			}
320 320
 		} else {
@@ -419,8 +419,9 @@  discard block
 block discarded – undo
419 419
 	 * @return string 		unix timestamp for utc
420 420
 	 */
421 421
 	private function _convert_to_utc_unix_timestamp( $datetime ) {
422
-		if ( $this->_nullable && empty( $datetime ) )
423
-			return NULL;
422
+		if ( $this->_nullable && empty( $datetime ) ) {
423
+					return NULL;
424
+		}
424 425
 		$timestamp = is_numeric( $datetime ) ? $this->_convert_from_numeric_value_to_utc_unix_timestamp( $datetime ) : $this->_convert_from_string_value_to_utc_unix_timestamp( $datetime );
425 426
 		return $timestamp;
426 427
 	}
@@ -588,16 +589,18 @@  discard block
 block discarded – undo
588 589
 
589 590
 		//first let's do a comparison of timezone strings.  If they match then we can get out without any further calculations
590 591
 		$blog_string = get_option('timezone_string');
591
-		if ( $blog_string == $this->_timezone )
592
-			return FALSE;
592
+		if ( $blog_string == $this->_timezone ) {
593
+					return FALSE;
594
+		}
593 595
 
594 596
 		//now we need to calc the offset for the timezone string so we can compare with the blog offset.
595 597
 		$this_offset = self::timezone_convert_to_offset_from_string( $this->_timezone );
596 598
 		$blog_offset = !empty( $this->_blog_offset ) ? $this->_blog_offset : self::timezone_convert_to_offset_from_string( $blog_string );
597 599
 
598 600
 		//now compare
599
-		if ( $blog_offset === $this_offset )
600
-			return FALSE;
601
+		if ( $blog_offset === $this_offset ) {
602
+					return FALSE;
603
+		}
601 604
 
602 605
 		return TRUE;
603 606
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -49,11 +49,11 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 	/**
52
-	 * @param      $table_column
52
+	 * @param      string $table_column
53 53
 	 * @param      $nice_name
54
-	 * @param      $nullable
54
+	 * @param      boolean $nullable
55 55
 	 * @param null $default_value
56
-	 * @param null $timezone
56
+	 * @param string|null $timezone
57 57
 	 * @param null $date_format
58 58
 	 * @param null $time_format
59 59
 	 * @param null $pretty_date_format
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
 	/**
98 98
 	 * this prepares any incoming date data and make sure its converted to a utc unix timestamp
99
-	 * @param  string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp
99
+	 * @param  string $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp
100 100
 	 * @return int                                           unix timestamp (utc)
101 101
 	 */
102 102
 	public function prepare_for_set($value_inputted_for_field_on_model_object) {
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @param mixed $datetime_value
309 309
 	 * @param string  $schema if set to "no_html", even if the timezone is shown, there will be no tags next to it.
310 310
 	 * @internal param mixed $value_on_field_to_be_outputted
311
-	 * @return mixed
311
+	 * @return string
312 312
 	 */
313 313
 	public function prepare_for_pretty_echoing( $datetime_value, $schema = null ) {
314 314
 		if( $this->_display_timezone() ) {
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 
454 454
 
455 455
 	/**
456
-	 * @param $datetime
456
+	 * @param string $datetime
457 457
 	 * @return string
458 458
 	 * @throws EE_Error
459 459
 	 */
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Integer_Field.php 2 patches
Spacing   +10 added lines, -10 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 . 'fields/EE_Integer_Field.php' );
2
+require_once(EE_MODELS.'fields/EE_Integer_Field.php');
3 3
 /**
4 4
  * Class EE_Enum_Integer_Field
5 5
  *
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @author				Mike Nelson
9 9
  *
10 10
  */
11
-class EE_Enum_Integer_Field extends EE_Integer_Field{
11
+class EE_Enum_Integer_Field extends EE_Integer_Field {
12 12
 
13 13
 	var $_allowed_enum_values;
14 14
 
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 	 * @param int $default_value
21 21
 	 * @param array $allowed_enum_values  keys are values to be used in the DB, values are how they should be displayed
22 22
 	 */
23
-	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values){
23
+	function __construct($table_column, $nicename, $nullable, $default_value, $allowed_enum_values) {
24 24
 		$this->_allowed_enum_values = $allowed_enum_values;
25 25
 		parent::__construct($table_column, $nicename, $nullable, $default_value);
26 26
 	}
@@ -32,21 +32,21 @@  discard block
 block discarded – undo
32 32
 	 * @throws EE_Error
33 33
 	 */
34 34
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
35
-		if( $value_inputted_for_field_on_model_object !== NULL && ! array_key_exists( $value_inputted_for_field_on_model_object, $this->_allowed_enum_values )){
36
-			if( defined( 'WP_DEBUG' ) && WP_DEBUG ){
35
+		if ($value_inputted_for_field_on_model_object !== NULL && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) {
36
+			if (defined('WP_DEBUG') && WP_DEBUG) {
37 37
 				$msg = sprintf(
38
-					__('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'),
38
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
39 39
 					$value_inputted_for_field_on_model_object,
40 40
 					$this->_name
41 41
 				);
42 42
 				$msg2 = sprintf(
43
-					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"','event_espresso'),
43
+					__('Allowed values for "%1$s" are "%2$s". You provided "%3$s"', 'event_espresso'),
44 44
 					$this->_name,
45
-					implode( ', ', array_keys( $this->_allowed_enum_values )),
45
+					implode(', ', array_keys($this->_allowed_enum_values)),
46 46
 					$value_inputted_for_field_on_model_object
47 47
 				);
48 48
 				throw new EE_Error("$msg||$msg2");
49
-			}else{
49
+			} else {
50 50
 				return $this->get_default_value();
51 51
 			}
52 52
 		}
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	 * @param null         $schema
63 63
 	 * @return string
64 64
 	 */
65
-	function prepare_for_pretty_echoing( $value_on_field_to_be_outputted, $schema = NULL ) {
65
+	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = NULL) {
66 66
 		return $this->_allowed_enum_values[$value_on_field_to_be_outputted];
67 67
 	}
68 68
 }
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
 require_once( EE_MODELS . 'fields/EE_Integer_Field.php' );
3 5
 /**
4 6
  * Class EE_Enum_Integer_Field
@@ -46,7 +48,7 @@  discard block
 block discarded – undo
46 48
 					$value_inputted_for_field_on_model_object
47 49
 				);
48 50
 				throw new EE_Error("$msg||$msg2");
49
-			}else{
51
+			} else{
50 52
 				return $this->get_default_value();
51 53
 			}
52 54
 		}
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
2
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
3 3
 /**
4 4
  *
5 5
  * Class EE_Enum_Text_Field
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @param mixed $default_value
24 24
 	 * @param array $allowed_enum_values  keys are values to be used in the DB, values are how they should be displayed
25 25
 	 */
26
-	function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values){
26
+	function __construct($table_column, $nice_name, $nullable, $default_value, $allowed_enum_values) {
27 27
 		$this->_allowed_enum_values = $allowed_enum_values;
28 28
 		parent::__construct($table_column, $nice_name, $nullable, $default_value);
29 29
 	}
@@ -38,12 +38,12 @@  discard block
 block discarded – undo
38 38
 	 * @throws EE_Error
39 39
 	 */
40 40
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
41
-		if($value_inputted_for_field_on_model_object!==null && !array_key_exists($value_inputted_for_field_on_model_object,$this->_allowed_enum_values)){
42
-			if(WP_DEBUG){
43
-				$msg = sprintf(__("System is assigning incompatible value '%s' to field '%s'",'event_espresso'),$value_inputted_for_field_on_model_object,$this->_name);
44
-				$msg2 = sprintf(__("Allowed values for '%s' are %s. You provided %s",'event_espresso'),$this->_name,implode(", ",array_keys($this->_allowed_enum_values)),$value_inputted_for_field_on_model_object);
41
+		if ($value_inputted_for_field_on_model_object !== null && ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)) {
42
+			if (WP_DEBUG) {
43
+				$msg = sprintf(__("System is assigning incompatible value '%s' to field '%s'", 'event_espresso'), $value_inputted_for_field_on_model_object, $this->_name);
44
+				$msg2 = sprintf(__("Allowed values for '%s' are %s. You provided %s", 'event_espresso'), $this->_name, implode(", ", array_keys($this->_allowed_enum_values)), $value_inputted_for_field_on_model_object);
45 45
 				throw new EE_Error("$msg||$msg2");
46
-			}else{
46
+			} else {
47 47
 				return $this->get_default_value();
48 48
 			}
49 49
 		}
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
 				$msg = sprintf(__("System is assigning incompatible value '%s' to field '%s'",'event_espresso'),$value_inputted_for_field_on_model_object,$this->_name);
44 44
 				$msg2 = sprintf(__("Allowed values for '%s' are %s. You provided %s",'event_espresso'),$this->_name,implode(", ",array_keys($this->_allowed_enum_values)),$value_inputted_for_field_on_model_object);
45 45
 				throw new EE_Error("$msg||$msg2");
46
-			}else{
46
+			} else{
47 47
 				return $this->get_default_value();
48 48
 			}
49 49
 		}
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -60,19 +60,19 @@
 block discarded – undo
60 60
 	private static function _timezone_convert_to_string_from_offset( $offset ) {
61 61
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
62 62
 		$offset *= 3600; // convert hour offset to seconds
63
-        $abbrarray = timezone_abbreviations_list();
64
-        foreach ($abbrarray as $abbr)
65
-        {
66
-                foreach ($abbr as $city)
67
-                {
68
-                        if ($city['offset'] === $offset && $city['dst'] === FALSE)
69
-                        {
70
-                                return $city['timezone_id'];
71
-                        }
72
-                }
73
-        }
74
-
75
-        return FALSE;
63
+		$abbrarray = timezone_abbreviations_list();
64
+		foreach ($abbrarray as $abbr)
65
+		{
66
+				foreach ($abbr as $city)
67
+				{
68
+						if ($city['offset'] === $offset && $city['dst'] === FALSE)
69
+						{
70
+								return $city['timezone_id'];
71
+						}
72
+				}
73
+		}
74
+
75
+		return FALSE;
76 76
 	}
77 77
 
78 78
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  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
 /**
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	public static function get_timezone() {
41 41
 		$timezone = get_option('timezone_string');
42 42
 		//if timezone is STILL empty then let's get the GMT offset and then set the timezone_string using our converter
43
-		if ( empty( $timezone ) ) {
43
+		if (empty($timezone)) {
44 44
 			//let's get a the WordPress UTC offset
45 45
 			$offset = get_option('gmt_offset');
46
-			$timezone = self::_timezone_convert_to_string_from_offset( $offset );
46
+			$timezone = self::_timezone_convert_to_string_from_offset($offset);
47 47
 		}
48 48
 		return $timezone;
49 49
 	}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @param  string $offset GMT offset
58 58
 	 * @return string         timezone_string (valid for DateTimeZone)
59 59
 	 */
60
-	private static function _timezone_convert_to_string_from_offset( $offset ) {
60
+	private static function _timezone_convert_to_string_from_offset($offset) {
61 61
 		//shamelessly taken from bottom comment at http://ca1.php.net/manual/en/function.timezone-name-from-abbr.php because timezone_name_from_abbr() did NOT work as expected - its not reliable
62 62
 		$offset *= 3600; // convert hour offset to seconds
63 63
         $abbrarray = timezone_abbreviations_list();
@@ -77,14 +77,14 @@  discard block
 block discarded – undo
77 77
 
78 78
 
79 79
 
80
-	public function prepare_dtt_from_db( $dttvalue, $format = 'U' ) {
80
+	public function prepare_dtt_from_db($dttvalue, $format = 'U') {
81 81
 		
82 82
 		$timezone = self::get_timezone();
83 83
 
84
-		$date_obj = new DateTime( $dttvalue, new DateTimeZone('UTC') );
85
-		if ( !$date_obj )
86
-			throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
87
-		$date_obj->setTimezone( new DateTimeZone($timezone) );
84
+		$date_obj = new DateTime($dttvalue, new DateTimeZone('UTC'));
85
+		if ( ! $date_obj)
86
+			throw new EE_Error(__('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso'));
87
+		$date_obj->setTimezone(new DateTimeZone($timezone));
88 88
 
89 89
 		return $date_obj->format($format);
90 90
 	}
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 
95 95
 
96 96
 	public static function ddtimezone($tz_event = '') {
97
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
97
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
98 98
 
99 99
 		$timezone_format = _x('Y-m-d G:i:s', 'timezone date format');
100 100
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 			if (0 == $current_offset)
113 113
 				$tzstring = 'UTC';
114 114
 			elseif ($current_offset < 0)
115
-				$tzstring = 'UTC' . $current_offset;
115
+				$tzstring = 'UTC'.$current_offset;
116 116
 			else
117
-				$tzstring = 'UTC+' . $current_offset;
117
+				$tzstring = 'UTC+'.$current_offset;
118 118
 		}
119 119
 		?>
120 120
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		</p>
127 127
 
128 128
 		<p><span><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n($timezone_format, false, 'gmt')); ?></span>
129
-			<?php if (get_option('timezone_string') || !empty($current_offset)) : ?>
129
+			<?php if (get_option('timezone_string') || ! empty($current_offset)) : ?>
130 130
 				<br /><span><?php printf(__('Local time is <code>%1$s</code>'), date_i18n($timezone_format)); ?></span>
131 131
 		<?php endif; ?>
132 132
 
@@ -159,10 +159,9 @@  discard block
 block discarded – undo
159 159
 						if ($found) {
160 160
 							echo ' ';
161 161
 							$message = $tr['isdst'] ?
162
-											__('Daylight saving time begins on: <code>%s</code>.') :
163
-											__('Standard time begins  on: <code>%s</code>.');
162
+											__('Daylight saving time begins on: <code>%s</code>.') : __('Standard time begins  on: <code>%s</code>.');
164 163
 							// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
165
-							printf($message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset'])));
164
+							printf($message, date_i18n(get_option('date_format').' '.get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset'])));
166 165
 						} else {
167 166
 							_e('This timezone does not observe daylight saving time.');
168 167
 						}
@@ -177,16 +176,16 @@  discard block
 block discarded – undo
177 176
 
178 177
 
179 178
 
180
-	public static function date_time_for_timezone( $timestamp, $format, $timezone ) {
181
-		$timezone = empty( $timezone ) ? self::get_timezone() : $timezone;
179
+	public static function date_time_for_timezone($timestamp, $format, $timezone) {
180
+		$timezone = empty($timezone) ? self::get_timezone() : $timezone;
182 181
 
183 182
 		//set timezone
184
-		date_default_timezone_set( $timezone );
183
+		date_default_timezone_set($timezone);
185 184
 
186
-		$date = date( $format, $timestamp );
185
+		$date = date($format, $timestamp);
187 186
 
188 187
 		//setback
189
-		date_default_timezone_set( 'UTC' );
188
+		date_default_timezone_set('UTC');
190 189
 		return $date;
191 190
 	}
192 191
 
@@ -199,7 +198,7 @@  discard block
 block discarded – undo
199 198
 	 * @param  integer       $value    what you want to increment the time by
200 199
 	 * @return EE_Base_Class		   return the EE_Base_Class object so right away you can do something with it (chaining)
201 200
 	 */
202
-	public static function date_time_add( EE_Base_Class $obj, $dttfield, $what = 'years', $value = 1 ) {
201
+	public static function date_time_add(EE_Base_Class $obj, $dttfield, $what = 'years', $value = 1) {
203 202
 		//get the raw UTC date.
204 203
 		$dtt = $obj->get_raw($dttfield);
205 204
 		$new_date = self::calc_date($dtt, $what, $value);
@@ -209,7 +208,7 @@  discard block
 block discarded – undo
209 208
 	}
210 209
 
211 210
 	//same as date_time_add except subtracting value instead of adding.
212
-	public static function date_time_subtract( EE_Base_Class $obj, $dttfield, $what = 'years', $value = 1 ) {
211
+	public static function date_time_subtract(EE_Base_Class $obj, $dttfield, $what = 'years', $value = 1) {
213 212
 		//get the raw UTC date
214 213
 		$dtt = $obj->get_raw($dttfield);
215 214
 		$new_date = self::calc_date($dtt, $what, $value, '-');
@@ -228,21 +227,21 @@  discard block
 block discarded – undo
228 227
 	 * @param  string  $operand What operand you wish to use for the calculation
229 228
 	 * @return string          new UTC timestamp
230 229
 	 */
231
-	public static function calc_date( $utcdtt, $what = 'years', $value = 1, $operand = '+' ) {
230
+	public static function calc_date($utcdtt, $what = 'years', $value = 1, $operand = '+') {
232 231
 		$newdtt = '';
233 232
 
234
-		switch ( $what ) {
233
+		switch ($what) {
235 234
 			case 'years' :
236
-				$value = (60*60*24*364.5) * $value;
235
+				$value = (60 * 60 * 24 * 364.5) * $value;
237 236
 				break;
238 237
 			case 'months' :
239
-				$value = (60*60*24*30.375) * $value;
238
+				$value = (60 * 60 * 24 * 30.375) * $value;
240 239
 				break;
241 240
 			case 'days' :
242
-				$value = (60*60*24) * $value;
241
+				$value = (60 * 60 * 24) * $value;
243 242
 				break;
244 243
 			case 'hours' :
245
-				$value = (60*60) * $value;
244
+				$value = (60 * 60) * $value;
246 245
 				break;
247 246
 			case 'minutes' :
248 247
 				$value = 60 * $value;
@@ -252,7 +251,7 @@  discard block
 block discarded – undo
252 251
 				break;
253 252
 		}
254 253
 
255
-		switch ( $operand ) {
254
+		switch ($operand) {
256 255
 			case '+':
257 256
 				$newdtt = $utcdtt + $value;
258 257
 				break;
Please login to merge, or discard this patch.
Braces   +20 added lines, -15 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
@@ -82,8 +83,9 @@  discard block
 block discarded – undo
82 83
 		$timezone = self::get_timezone();
83 84
 
84 85
 		$date_obj = new DateTime( $dttvalue, new DateTimeZone('UTC') );
85
-		if ( !$date_obj )
86
-			throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
86
+		if ( !$date_obj ) {
87
+					throw new EE_Error( __('Something went wrong with setting the date/time. Likely, either there is an invalid datetime string or an invalid timezone string being used.', 'event_espresso' ) );
88
+		}
87 89
 		$date_obj->setTimezone( new DateTimeZone($timezone) );
88 90
 
89 91
 		return $date_obj->format($format);
@@ -104,17 +106,19 @@  discard block
 block discarded – undo
104 106
 		$check_zone_info = true;
105 107
 
106 108
 		// Remove old Etc mappings.  Fallback to gmt_offset.
107
-		if (false !== strpos($tzstring, 'Etc/GMT'))
108
-			$tzstring = '';
109
+		if (false !== strpos($tzstring, 'Etc/GMT')) {
110
+					$tzstring = '';
111
+		}
109 112
 
110 113
 		if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists
111 114
 			$check_zone_info = false;
112
-			if (0 == $current_offset)
113
-				$tzstring = 'UTC';
114
-			elseif ($current_offset < 0)
115
-				$tzstring = 'UTC' . $current_offset;
116
-			else
117
-				$tzstring = 'UTC+' . $current_offset;
115
+			if (0 == $current_offset) {
116
+							$tzstring = 'UTC';
117
+			} elseif ($current_offset < 0) {
118
+							$tzstring = 'UTC' . $current_offset;
119
+			} else {
120
+							$tzstring = 'UTC+' . $current_offset;
121
+			}
118 122
 		}
119 123
 		?>
120 124
 
@@ -137,10 +141,11 @@  discard block
 block discarded – undo
137 141
 					// Set TZ so localtime works.
138 142
 					date_default_timezone_set($tzstring);
139 143
 					$now = localtime(time(), true);
140
-					if ($now['tm_isdst'])
141
-						_e('This timezone is currently in daylight saving time.');
142
-					else
143
-						_e('This timezone is currently in standard time.');
144
+					if ($now['tm_isdst']) {
145
+											_e('This timezone is currently in daylight saving time.');
146
+					} else {
147
+											_e('This timezone is currently in standard time.');
148
+					}
144 149
 					?>
145 150
 					<br />
146 151
 					<?php
Please login to merge, or discard this patch.