Completed
Branch BETA-4.9-messages-queue-fixed (941081)
by
unknown
30:24 queued 05:56
created
core/db_models/EEM_CPT_Base.model.php 1 patch
Spacing   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-define('EE_Event_Category_Taxonomy','espresso_event_category');
2
+define('EE_Event_Category_Taxonomy', 'espresso_event_category');
3 3
 /**
4 4
  *
5 5
  * EEM_CPT_Base
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @author 				Mike Nelson
17 17
  *
18 18
  */
19
-abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base{
19
+abstract class EEM_CPT_Base extends EEM_Soft_Delete_Base {
20 20
 
21 21
 	/**
22 22
 	 * @var string post_status_trashed - the wp post status for trashed cpts
@@ -44,46 +44,46 @@  discard block
 block discarded – undo
44 44
 	 * @param string $timezone
45 45
 	 * @throws \EE_Error
46 46
 	 */
47
-	protected function __construct( $timezone = NULL ){
47
+	protected function __construct($timezone = NULL) {
48 48
 
49 49
 		//adds a relationship to Term_Taxonomy for all these models. For this to work
50 50
 		//Term_Relationship must have a relation to each model subclassing EE_CPT_Base explicitly
51 51
 		//eg, in EEM_Term_Relationship, inside the _model_relations array, there must be an entry
52 52
 		//with key equalling the subclassing model's model name (eg 'Event' or 'Venue'), and the value
53 53
 		//must also be new EE_HABTM_Relation('Term_Relationship');
54
-		$this->_model_relations['Term_Taxonomy'] =new EE_HABTM_Relation('Term_Relationship');
54
+		$this->_model_relations['Term_Taxonomy'] = new EE_HABTM_Relation('Term_Relationship');
55 55
 		$primary_table_name = NULL;
56 56
 		//add  the common _status field to all CPT primary tables.
57
-		foreach ( $this->_tables as $alias => $table_obj ) {
58
-			if ( $table_obj instanceof EE_Primary_Table ) {
57
+		foreach ($this->_tables as $alias => $table_obj) {
58
+			if ($table_obj instanceof EE_Primary_Table) {
59 59
 				$primary_table_name = $alias;
60 60
 			}
61 61
 		}
62 62
 		//set default wp post statuses if child has not already set.
63
-		if ( ! isset( $this->_fields[$primary_table_name]['status'] )) {
63
+		if ( ! isset($this->_fields[$primary_table_name]['status'])) {
64 64
 			$this->_fields[$primary_table_name]['status'] = new EE_WP_Post_Status_Field('post_status', __("Event Status", "event_espresso"), false, 'draft');
65 65
 		}
66
-		if( ! isset( $this->_fields[$primary_table_name]['to_ping'])){
67
-			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __( 'To Ping', 'event_espresso' ), FALSE, '');
66
+		if ( ! isset($this->_fields[$primary_table_name]['to_ping'])) {
67
+			$this->_fields[$primary_table_name]['to_ping'] = new EE_DB_Only_Text_Field('to_ping', __('To Ping', 'event_espresso'), FALSE, '');
68 68
 		}
69
-		if( ! isset( $this->_fields[$primary_table_name]['pinged'])){
70
-			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __( 'Pinged', 'event_espresso' ), FALSE, '');
69
+		if ( ! isset($this->_fields[$primary_table_name]['pinged'])) {
70
+			$this->_fields[$primary_table_name]['pinged'] = new EE_DB_Only_Text_Field('pinged', __('Pinged', 'event_espresso'), FALSE, '');
71 71
 		}
72 72
 
73
-		if( ! isset( $this->_fields[$primary_table_name]['comment_status'])){
74
-			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso' ), FALSE, 'open');
73
+		if ( ! isset($this->_fields[$primary_table_name]['comment_status'])) {
74
+			$this->_fields[$primary_table_name]['comment_status'] = new EE_Plain_Text_Field('comment_status', __('Comment Status', 'event_espresso'), FALSE, 'open');
75 75
 		}
76 76
 
77
-		if( ! isset( $this->_fields[$primary_table_name]['ping_status'])){
77
+		if ( ! isset($this->_fields[$primary_table_name]['ping_status'])) {
78 78
 			$this->_fields[$primary_table_name]['ping_status'] = new EE_Plain_Text_Field('ping_status', __('Ping Status', 'event_espresso'), FALSE, 'open');
79 79
 		}
80 80
 
81
-		if( ! isset( $this->_fields[$primary_table_name]['post_content_filtered'])){
82
-			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __( 'Post Content Filtered', 'event_espresso' ), FALSE, '');
81
+		if ( ! isset($this->_fields[$primary_table_name]['post_content_filtered'])) {
82
+			$this->_fields[$primary_table_name]['post_content_filtered'] = new EE_DB_Only_Text_Field('post_content_filtered', __('Post Content Filtered', 'event_espresso'), FALSE, '');
83 83
 		}
84
-		if( ! isset( $this->_model_relations[ 'Post_Meta' ] ) ) {
84
+		if ( ! isset($this->_model_relations['Post_Meta'])) {
85 85
 			//don't block deletes though because we want to maintain the current behaviour
86
-			$this->_model_relations[ 'Post_Meta' ] = new EE_Has_Many_Relation( false );
86
+			$this->_model_relations['Post_Meta'] = new EE_Has_Many_Relation(false);
87 87
 		}
88 88
 		parent::__construct($timezone);
89 89
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function public_event_stati() {
98 98
 		// @see wp-includes/post.php
99
-		return get_post_stati( array( 'public' => TRUE ));
99
+		return get_post_stati(array('public' => TRUE));
100 100
 	}
101 101
 
102 102
 
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return string
108 108
 	 * @throws EE_Error
109 109
 	 */
110
-	public function deleted_field_name(){
110
+	public function deleted_field_name() {
111 111
 		throw new EE_Error(sprintf(__("EEM_CPT_Base should nto call deleted_field_name! It should instead use post_status_field_name", "event_espresso")));
112 112
 	}
113 113
 
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 * @return string
119 119
 	 * @throws EE_Error
120 120
 	 */
121
-	public function post_status_field_name(){
121
+	public function post_status_field_name() {
122 122
 		$field = $this->get_a_field_of_type('EE_WP_Post_Status_Field');
123
-		if($field){
123
+		if ($field) {
124 124
 			return $field->get_name();
125
-		}else{
126
-			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?','event_espresso'),get_class($this),get_class($this)));
125
+		} else {
126
+			throw new EE_Error(sprintf(__('We are trying to find the post status flag field on %s, but none was found. Are you sure there is a field of type EE_Trashed_Flag_Field in %s constructor?', 'event_espresso'), get_class($this), get_class($this)));
127 127
 		}
128 128
 	}
129 129
 
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
 	 * @param array $query_params like EEM_Base::get_all's $query_params
135 135
 	 * @return array like EEM_Base::get_all's $query_params
136 136
 	 */
137
-	protected function _alter_query_params_so_only_trashed_items_included($query_params){
138
-		$post_status_field_name=$this->post_status_field_name();
139
-		$query_params[0][$post_status_field_name]=self::post_status_trashed;
137
+	protected function _alter_query_params_so_only_trashed_items_included($query_params) {
138
+		$post_status_field_name = $this->post_status_field_name();
139
+		$query_params[0][$post_status_field_name] = self::post_status_trashed;
140 140
 		return $query_params;
141 141
 	}
142 142
 
@@ -147,9 +147,9 @@  discard block
 block discarded – undo
147 147
 	 * @param array $query_params
148 148
 	 * @return array
149 149
 	 */
150
-	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params){
151
-		$post_status_field_name=$this->post_status_field_name();
152
-		$query_params[0][$post_status_field_name]=array('IN',array_keys($this->get_status_array()));
150
+	protected function _alter_query_params_so_deleted_and_undeleted_items_included($query_params) {
151
+		$post_status_field_name = $this->post_status_field_name();
152
+		$query_params[0][$post_status_field_name] = array('IN', array_keys($this->get_status_array()));
153 153
 		return $query_params;
154 154
 	}
155 155
 
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 	 * @param array $query_params like EEM_Base::get_all
162 162
 	 * @return boolean success
163 163
 	 */
164
-	function delete_or_restore($delete=true,$query_params = array()){
165
-		$post_status_field_name=$this->post_status_field_name();
164
+	function delete_or_restore($delete = true, $query_params = array()) {
165
+		$post_status_field_name = $this->post_status_field_name();
166 166
 		$query_params = $this->_alter_query_params_so_deleted_and_undeleted_items_included($query_params);
167 167
 		$new_status = $delete ? self::post_status_trashed : 'draft';
168
-		if ( $this->update (array($post_status_field_name=>$new_status), $query_params )) {
168
+		if ($this->update(array($post_status_field_name=>$new_status), $query_params)) {
169 169
 			return TRUE;
170 170
 		} else {
171 171
 			return FALSE;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function meta_table() {
184 184
 		$meta_table = $this->_get_other_tables();
185
-		$meta_table = reset( $meta_table );
185
+		$meta_table = reset($meta_table);
186 186
 		return $meta_table instanceof EE_Secondary_Table ? $meta_table->get_table_name() : NULL;
187 187
 	}
188 188
 
@@ -194,16 +194,16 @@  discard block
 block discarded – undo
194 194
 	 * @param  bool $all triggers whether we include DB_Only fields or JUST non DB_Only fields.  Defaults to false (no db only fields)
195 195
 	 * @return array
196 196
 	 */
197
-	public function get_meta_table_fields( $all = FALSE ) {
197
+	public function get_meta_table_fields($all = FALSE) {
198 198
 		$all_fields = $fields_to_return = array();
199
-		foreach ( $this->_tables as $alias => $table_obj ) {
200
-			if ( $table_obj instanceof EE_Secondary_Table )
201
-				$all_fields = array_merge( $this->_get_fields_for_table($alias), $all_fields );
199
+		foreach ($this->_tables as $alias => $table_obj) {
200
+			if ($table_obj instanceof EE_Secondary_Table)
201
+				$all_fields = array_merge($this->_get_fields_for_table($alias), $all_fields);
202 202
 		}
203 203
 
204
-		if ( !$all ) {
205
-			foreach ( $all_fields as $name => $obj ) {
206
-				if ( $obj instanceof EE_DB_Only_Field_Base )
204
+		if ( ! $all) {
205
+			foreach ($all_fields as $name => $obj) {
206
+				if ($obj instanceof EE_DB_Only_Field_Base)
207 207
 					continue;
208 208
 				$fields_to_return[] = $name;
209 209
 			}
@@ -226,13 +226,13 @@  discard block
 block discarded – undo
226 226
 	 * @param int $parent_term_taxonomy_id
227 227
 	 * @return EE_Term_Taxonomy
228 228
 	 */
229
-	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description ='',$parent_term_taxonomy_id = null){
229
+	function add_event_category(EE_CPT_Base $cpt_model_object, $category_name, $category_description = '', $parent_term_taxonomy_id = null) {
230 230
 		//create term
231
-		require_once( EE_MODELS . 'EEM_Term.model.php');
231
+		require_once(EE_MODELS.'EEM_Term.model.php');
232 232
 		//first, check for a term by the same name or slug
233 233
 		$category_slug = sanitize_title($category_name);
234
-		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name,'slug'=>$category_slug))));
235
-		if( ! $term ){
234
+		$term = EEM_Term::instance()->get_one(array(array('OR'=>array('name'=>$category_name, 'slug'=>$category_slug))));
235
+		if ( ! $term) {
236 236
 			$term = EE_Term::new_instance(array(
237 237
 				'name'=>$category_name,
238 238
 				'slug'=>$category_slug
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
 			$term->save();
241 241
 		}
242 242
 		//make sure there's a term-taxonomy entry too
243
-		require_once( EE_MODELS . 'EEM_Term_Taxonomy.model.php');
244
-		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(),'taxonomy'=>EE_Event_Category_Taxonomy)));
243
+		require_once(EE_MODELS.'EEM_Term_Taxonomy.model.php');
244
+		$term_taxonomy = EEM_Term_Taxonomy::instance()->get_one(array(array('term_id'=>$term->ID(), 'taxonomy'=>EE_Event_Category_Taxonomy)));
245 245
 		/** @var $term_taxonomy EE_Term_Taxonomy */
246
-		if( ! $term_taxonomy ){
246
+		if ( ! $term_taxonomy) {
247 247
 			$term_taxonomy = EE_Term_Taxonomy::new_instance(array(
248 248
 				'term_id'=>$term->ID(),
249 249
 				'taxonomy'=>EE_Event_Category_Taxonomy,
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 				'parent'=>$parent_term_taxonomy_id
253 253
 			));
254 254
 			$term_taxonomy->save();
255
-		}else{
255
+		} else {
256 256
 			$term_taxonomy->set_count($term_taxonomy->count() + 1);
257 257
 			$term_taxonomy->save();
258 258
 		}
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 	 * @param string $category_name name of the event category (term)
268 268
 	 * @return bool
269 269
 	 */
270
-	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name){
270
+	function remove_event_category(EE_CPT_Base $cpt_model_object_event, $category_name) {
271 271
 		//find the term_taxonomy by that name
272
-		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name,'taxonomy'=>EE_Event_Category_Taxonomy)));
272
+		$term_taxonomy = $this->get_first_related($cpt_model_object_event, 'Term_Taxonomy', array(array('Term.name'=>$category_name, 'taxonomy'=>EE_Event_Category_Taxonomy)));
273 273
 		/** @var $term_taxonomy EE_Term_Taxonomy */
274
-		if( $term_taxonomy ){
274
+		if ($term_taxonomy) {
275 275
 			$term_taxonomy->set_count($term_taxonomy->count() - 1);
276 276
 			$term_taxonomy->save();
277 277
 		}
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 	 * @param string|array $attr Optional. Query string or array of attributes.
292 292
 	 * @return string HTML image element
293 293
 	 */
294
-	public function get_feature_image( $id, $size = 'thumbnail', $attr = '' ) {
295
-		return get_the_post_thumbnail( $id, $size, $attr );
294
+	public function get_feature_image($id, $size = 'thumbnail', $attr = '') {
295
+		return get_the_post_thumbnail($id, $size, $attr);
296 296
 	}
297 297
 
298 298
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 	 * @global array $wp_post_statuses set in wp core for storing all the post stati
306 306
 	 * @return array
307 307
 	 */
308
-	public function get_post_statuses(){
308
+	public function get_post_statuses() {
309 309
 		global $wp_post_statuses;
310 310
 		$statuses = array();
311
-		foreach($wp_post_statuses as $post_status => $args_object){
311
+		foreach ($wp_post_statuses as $post_status => $args_object) {
312 312
 			$statuses[$post_status] = $args_object->label;
313 313
 		}
314 314
 		return $statuses;
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	public function get_status_array() {
324 324
 		$statuses = $this->get_post_statuses();
325 325
 		//first the global filter
326
-		$statuses = apply_filters( 'FHEE_EEM_CPT_Base__get_status_array', $statuses );
326
+		$statuses = apply_filters('FHEE_EEM_CPT_Base__get_status_array', $statuses);
327 327
 		//now the class specific filter
328
-		$statuses = apply_filters( 'FHEE_EEM_' . get_class($this) . '__get_status_array', $statuses );
328
+		$statuses = apply_filters('FHEE_EEM_'.get_class($this).'__get_status_array', $statuses);
329 329
 		return $statuses;
330 330
 	}
331 331
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	public function get_custom_post_statuses() {
339 339
 		$new_stati = array();
340
-		foreach ( $this->_custom_stati as $status => $props ) {
340
+		foreach ($this->_custom_stati as $status => $props) {
341 341
 			$new_stati[$status] = $props['label'];
342 342
 		}
343 343
 		return $new_stati;
@@ -353,24 +353,24 @@  discard block
 block discarded – undo
353 353
 	 * @param WP_Post|array $post
354 354
 	 * @return EE_CPT_Base
355 355
 	 */
356
-	public function instantiate_class_from_post_object_orig($post){
357
-		$post = (array)$post;
356
+	public function instantiate_class_from_post_object_orig($post) {
357
+		$post = (array) $post;
358 358
 		$has_all_necessary_fields_for_table = true;
359 359
 		//check if the post has fields on the meta table already
360
-		foreach($this->_get_other_tables() as $table_obj){
360
+		foreach ($this->_get_other_tables() as $table_obj) {
361 361
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
362
-			foreach($fields_for_that_table as $field_obj){
363
-				if( ! isset($post[$field_obj->get_table_column()])
364
-					&& ! isset($post[$field_obj->get_qualified_column()])){
362
+			foreach ($fields_for_that_table as $field_obj) {
363
+				if ( ! isset($post[$field_obj->get_table_column()])
364
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
365 365
 					$has_all_necessary_fields_for_table = false;
366 366
 				}
367 367
 			}
368 368
 		}
369 369
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
370
-		if( ! $has_all_necessary_fields_for_table){
370
+		if ( ! $has_all_necessary_fields_for_table) {
371 371
 
372 372
 			return $this->get_one_by_ID($post['ID']);
373
-		}else{
373
+		} else {
374 374
 			return $this->instantiate_class_from_array_or_object($post);
375 375
 		}
376 376
 	}
@@ -381,30 +381,30 @@  discard block
 block discarded – undo
381 381
 	 * @param null $post
382 382
 	 * @return EE_Base_Class|EE_Soft_Delete_Base_Class
383 383
 	 */
384
-	public function instantiate_class_from_post_object( $post = NULL ){
385
-		if ( empty( $post )) {
384
+	public function instantiate_class_from_post_object($post = NULL) {
385
+		if (empty($post)) {
386 386
 			global $post;
387 387
 		}
388
-		$post = (array)$post;
388
+		$post = (array) $post;
389 389
 		$tables_needing_to_be_queried = array();
390 390
 		//check if the post has fields on the meta table already
391
-		foreach($this->get_tables() as $table_obj){
391
+		foreach ($this->get_tables() as $table_obj) {
392 392
 			$fields_for_that_table = $this->_get_fields_for_table($table_obj->get_table_alias());
393
-			foreach($fields_for_that_table as $field_obj){
394
-				if( ! isset($post[$field_obj->get_table_column()])
395
-					&& ! isset($post[$field_obj->get_qualified_column()])){
393
+			foreach ($fields_for_that_table as $field_obj) {
394
+				if ( ! isset($post[$field_obj->get_table_column()])
395
+					&& ! isset($post[$field_obj->get_qualified_column()])) {
396 396
 					$tables_needing_to_be_queried[$table_obj->get_table_alias()] = $table_obj;
397 397
 				}
398 398
 			}
399 399
 		}
400 400
 		//if we don't have all the fields we need, then just fetch the proper model from the DB
401
-		if( $tables_needing_to_be_queried){
402
-			if(count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table){
401
+		if ($tables_needing_to_be_queried) {
402
+			if (count($tables_needing_to_be_queried) == 1 && reset($tables_needing_to_be_queried) instanceof EE_Secondary_Table) {
403 403
 				//so we're only missing data from a secondary table. Well that's not too hard to query for
404 404
 				$table_to_query = reset($tables_needing_to_be_queried);
405
-				$missing_data = $this->_do_wpdb_query( 'get_row', array( 'SELECT * FROM ' . $table_to_query->get_table_name() . ' WHERE ' . $table_to_query->get_fk_on_table() . ' = ' . $post['ID'], ARRAY_A ));
406
-				if ( ! empty( $missing_data )) {
407
-					$post = array_merge( $post, $missing_data );
405
+				$missing_data = $this->_do_wpdb_query('get_row', array('SELECT * FROM '.$table_to_query->get_table_name().' WHERE '.$table_to_query->get_fk_on_table().' = '.$post['ID'], ARRAY_A));
406
+				if ( ! empty($missing_data)) {
407
+					$post = array_merge($post, $missing_data);
408 408
 				}
409 409
 			} else {
410 410
 				return $this->get_one_by_ID($post['ID']);
@@ -421,15 +421,15 @@  discard block
 block discarded – undo
421 421
 	 * @throws EE_Error
422 422
 	 * @return string
423 423
 	 */
424
-	public function post_type(){
424
+	public function post_type() {
425 425
 		$post_type_field = NULL;
426
-		foreach($this->field_settings(true) as $field_obj){
427
-			if($field_obj instanceof EE_WP_Post_Type_Field){
428
-				$post_type_field = $field_obj;break;
426
+		foreach ($this->field_settings(true) as $field_obj) {
427
+			if ($field_obj instanceof EE_WP_Post_Type_Field) {
428
+				$post_type_field = $field_obj; break;
429 429
 			}
430 430
 		}
431
-		if($post_type_field == NULL){
432
-			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"),get_class($this)));
431
+		if ($post_type_field == NULL) {
432
+			throw new EE_Error(sprintf(__("CPT Model %s should have a field of type EE_WP_Post_Type, but doesnt", "event_espresso"), get_class($this)));
433 433
 		}
434 434
 		return $post_type_field->get_default_value();
435 435
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime.model.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 
76 76
 
77 77
 	/**
78
-	*		create new blank datetime
79
-	*
80
-	* 		@access		public
81
-	*		@return 		EE_Datetime[]		array on success, FALSE on fail
82
-	*/
78
+	 *		create new blank datetime
79
+	 *
80
+	 * 		@access		public
81
+	 *		@return 		EE_Datetime[]		array on success, FALSE on fail
82
+	 */
83 83
 	public function create_new_blank_datetime() {
84 84
 		$blank_datetime = EE_Datetime::new_instance(
85 85
 			array(
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
 
101 101
 
102 102
 	/**
103
-	*		get event start date from db
104
-	*
105
-	* 		@access		public
106
-	* 		@param		int 			$EVT_ID
107
-	*		@return 		EE_Datetime[]		array on success, FALSE on fail
108
-	*/
103
+	 *		get event start date from db
104
+	 *
105
+	 * 		@access		public
106
+	 * 		@param		int 			$EVT_ID
107
+	 *		@return 		EE_Datetime[]		array on success, FALSE on fail
108
+	 */
109 109
 	public function get_all_event_dates( $EVT_ID = 0 ) {
110 110
 		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
111 111
 			return $this->create_new_blank_datetime();
@@ -250,14 +250,14 @@  discard block
 block discarded – undo
250 250
 	}
251 251
 
252 252
 		/**
253
-	 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
254
-	 * only by start date
255
-	 * @param int $TKT_ID
256
-	 * @param boolean $include_expired
257
-	 * @param boolean $include_deleted
258
-	 * @param int $limit
259
-	 * @return EE_Datetime[]
260
-	 */
253
+		 * Gets ALL the datetimes for an ticket (including trashed ones, for now), ordered
254
+		 * only by start date
255
+		 * @param int $TKT_ID
256
+		 * @param boolean $include_expired
257
+		 * @param boolean $include_deleted
258
+		 * @param int $limit
259
+		 * @return EE_Datetime[]
260
+		 */
261 261
 	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
262 262
 		//sanitize TKT_ID
263 263
 		$TKT_ID =  intval( $TKT_ID );
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -443,7 +443,7 @@
 block discarded – undo
443 443
 	/**
444 444
 	 * This returns an array of counts of datetimes in the database for each Datetime status that can be queried.
445 445
 	 *
446
-	 * @param  array $stati_to_include        If included you can restrict the statuses we return counts for by including the stati
446
+	 * @param  string[] $stati_to_include        If included you can restrict the statuses we return counts for by including the stati
447 447
 	 *                               you want counts for as values in the array.  An empty array returns counts for all valid
448 448
 	 *                               stati.
449 449
 	 * @param  array  $query_params  If included can be used to refine the conditions for returning the count (i.e. only for
Please login to merge, or discard this patch.
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Datetime.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime.class.php');
26 26
 
27 27
 class EEM_Datetime extends EEM_Soft_Delete_Base {
28 28
 
@@ -35,27 +35,27 @@  discard block
 block discarded – undo
35 35
 	 *		@access private
36 36
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
37 37
 	 */
38
-	protected function __construct( $timezone ) {
39
-		$this->singular_item = __('Datetime','event_espresso');
40
-		$this->plural_item = __('Datetimes','event_espresso');
38
+	protected function __construct($timezone) {
39
+		$this->singular_item = __('Datetime', 'event_espresso');
40
+		$this->plural_item = __('Datetimes', 'event_espresso');
41 41
 
42 42
 		$this->_tables = array(
43 43
 			'Datetime'=> new EE_Primary_Table('esp_datetime', 'DTT_ID')
44 44
 		);
45 45
 		$this->_fields = array(
46 46
 			'Datetime'=>array(
47
-				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID','event_espresso')),
48
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
47
+				'DTT_ID'=> new EE_Primary_Key_Int_Field('DTT_ID', __('Datetime ID', 'event_espresso')),
48
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
49 49
 				'DTT_name' => new EE_Plain_Text_Field('DTT_name', __('Datetime Name', 'event_espresso'), false, ''),
50 50
 				'DTT_description' => new EE_Full_HTML_Field('DTT_description', __('Description for Datetime', 'event_espresso'), false, ''),
51
-				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event','event_espresso'), false, time(), $timezone ),
52
-				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event','event_espresso'), false, time(), $timezone ),
53
-				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time','event_espresso'), true, EE_INF),
54
-				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0 ),
55
-				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false,false),
51
+				'DTT_EVT_start'=>new EE_Datetime_Field('DTT_EVT_start', __('Start time/date of Event', 'event_espresso'), false, time(), $timezone),
52
+				'DTT_EVT_end'=>new EE_Datetime_Field('DTT_EVT_end', __('End time/date of Event', 'event_espresso'), false, time(), $timezone),
53
+				'DTT_reg_limit'=>new EE_Infinite_Integer_Field('DTT_reg_limit', __('Registration Limit for this time', 'event_espresso'), true, EE_INF),
54
+				'DTT_sold'=>new EE_Integer_Field('DTT_sold', __('How many sales for this Datetime that have occurred', 'event_espresso'), true, 0),
55
+				'DTT_is_primary'=>new EE_Boolean_Field('DTT_is_primary', __("Flag indicating datetime is primary one for event", "event_espresso"), false, false),
56 56
 				'DTT_order' => new EE_Integer_Field('DTT_order', __('The order in which the Datetime is displayed', 'event_espresso'), false, 0),
57
-				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0 ),
58
-				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false ),
57
+				'DTT_parent' => new EE_Integer_Field('DTT_parent', __('Indicates what DTT_ID is the parent of this DTT_ID'), true, 0),
58
+				'DTT_deleted' => new EE_Trashed_Flag_Field('DTT_deleted', __('Flag indicating datetime is archived', 'event_espresso'), false, false),
59 59
 			));
60 60
 		$this->_model_relations = array(
61 61
 			'Ticket'=>new EE_HABTM_Relation('Datetime_Ticket'),
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
 		);
65 65
 		$this->_model_chain_to_wp_user = 'Event';
66 66
 		//this model is generally available for reading
67
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( 'Event' );
68
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
69
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event' );
70
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( 'Event', EEM_Base::caps_edit );
71
-		parent::__construct( $timezone );
67
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public('Event');
68
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected('Event');
69
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected('Event');
70
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected('Event', EEM_Base::caps_edit);
71
+		parent::__construct($timezone);
72 72
 	}
73 73
 
74 74
 
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 	public function create_new_blank_datetime() {
84 84
 		$blank_datetime = EE_Datetime::new_instance(
85 85
 			array(
86
-				'DTT_EVT_start' => $this->current_time_for_query( 'DTT_EVT_start', true ) + (60 * 60 * 24 * 30),
87
-				'DTT_EVT_end' => $this->current_time_for_query( 'DTT_EVT_end', true ) + (60 * 60 * 24 * 30),
86
+				'DTT_EVT_start' => $this->current_time_for_query('DTT_EVT_start', true) + (60 * 60 * 24 * 30),
87
+				'DTT_EVT_end' => $this->current_time_for_query('DTT_EVT_end', true) + (60 * 60 * 24 * 30),
88 88
 				'DTT_order' => 1,
89 89
 				'DTT_reg_limit' => EE_INF
90 90
 			),
91 91
 			$this->_timezone
92 92
 		);
93
-		$blank_datetime->set_start_time( $this->convert_datetime_for_query( 'DTT_EVT_start', '8am', 'ga', $this->_timezone ) );
94
-		$blank_datetime->set_end_time( $this->convert_datetime_for_query( 'DTT_EVT_end', '5pm', 'ga', $this->_timezone ) );
95
-		return array( $blank_datetime );
93
+		$blank_datetime->set_start_time($this->convert_datetime_for_query('DTT_EVT_start', '8am', 'ga', $this->_timezone));
94
+		$blank_datetime->set_end_time($this->convert_datetime_for_query('DTT_EVT_end', '5pm', 'ga', $this->_timezone));
95
+		return array($blank_datetime);
96 96
 	}
97 97
 
98 98
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	* 		@param		int 			$EVT_ID
107 107
 	*		@return 		EE_Datetime[]		array on success, FALSE on fail
108 108
 	*/
109
-	public function get_all_event_dates( $EVT_ID = 0 ) {
110
-		if ( ! $EVT_ID ) { // on add_new_event event_id gets set to 0
109
+	public function get_all_event_dates($EVT_ID = 0) {
110
+		if ( ! $EVT_ID) { // on add_new_event event_id gets set to 0
111 111
 			return $this->create_new_blank_datetime();
112 112
 		}
113
-		$results =  $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
113
+		$results = $this->get_datetimes_for_event_ordered_by_DTT_order($EVT_ID);
114 114
 
115
-		if ( empty( $results ) ) {
115
+		if (empty($results)) {
116 116
 			return $this->create_new_blank_datetime();
117 117
 		}
118 118
 
@@ -133,26 +133,26 @@  discard block
 block discarded – undo
133 133
 	 *                        	the given number
134 134
 	 * @return EE_Datetime[]
135 135
 	 */
136
-	public function get_datetimes_for_event_ordered_by_DTT_order( $EVT_ID, $include_expired = TRUE, $include_deleted= TRUE, $limit = NULL  ) {
136
+	public function get_datetimes_for_event_ordered_by_DTT_order($EVT_ID, $include_expired = TRUE, $include_deleted = TRUE, $limit = NULL) {
137 137
 
138 138
 		//sanitize EVT_ID
139
-		$EVT_ID = intval( $EVT_ID );
139
+		$EVT_ID = intval($EVT_ID);
140 140
 
141 141
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
142
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
143
-		$where_params = array( 'Event.EVT_ID' => $EVT_ID );
142
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
143
+		$where_params = array('Event.EVT_ID' => $EVT_ID);
144 144
 
145
-		$query_params = ! empty( $limit ) ? array( $where_params, 'limit' => $limit, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' ) : array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ), 'default_where_conditions' => 'none' );
145
+		$query_params = ! empty($limit) ? array($where_params, 'limit' => $limit, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none') : array($where_params, 'order_by' => array('DTT_order' => 'ASC'), 'default_where_conditions' => 'none');
146 146
 
147
-		if( ! $include_expired){
148
-			$query_params[0]['DTT_EVT_end'] = array( '>=', current_time( 'mysql', TRUE ) );
147
+		if ( ! $include_expired) {
148
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
149 149
 		}
150
-		if( $include_deleted){
151
-			$query_params[0]['DTT_deleted'] = array( 'IN', array( TRUE, FALSE ));
150
+		if ($include_deleted) {
151
+			$query_params[0]['DTT_deleted'] = array('IN', array(TRUE, FALSE));
152 152
 		}
153 153
 
154
-		$result = $this->get_all( $query_params );
155
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
154
+		$result = $this->get_all($query_params);
155
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
156 156
 		return $result;
157 157
 	}
158 158
 
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
 	 * @param int $limit
168 168
 	 * @return EE_Datetime[]
169 169
 	 */
170
-	public function get_datetimes_for_event_ordered_by_importance( $EVT_ID = 0, $limit = NULL){
171
-		return $this->get_all( array(array('Event.EVT_ID'=>$EVT_ID),
170
+	public function get_datetimes_for_event_ordered_by_importance($EVT_ID = 0, $limit = NULL) {
171
+		return $this->get_all(array(array('Event.EVT_ID'=>$EVT_ID),
172 172
 			'limit'=>$limit,
173 173
 			'order_by'=>array('DTT_EVT_start'=>'ASC'),
174 174
 			'default_where_conditions' => 'none'));
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @param boolean $include_deleted
184 184
 	 * @return EE_Datetime
185 185
 	 */
186
-	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false,$include_deleted = false){
187
-		$results =  $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
-		if($results){
186
+	public function get_oldest_datetime_for_event($EVT_ID, $include_expired = false, $include_deleted = false) {
187
+		$results = $this->get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired, $include_deleted, 1);
188
+		if ($results) {
189 189
 			return array_shift($results);
190
-		}else{
190
+		} else {
191 191
 			return NULL;
192 192
 		}
193 193
 	}
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 	 * @param bool $try_to_exclude_deleted
202 202
 	 * @return \EE_Datetime
203 203
 	 */
204
-	public function get_primary_datetime_for_event($EVT_ID,$try_to_exclude_expired = true, $try_to_exclude_deleted = true){
205
-		if($try_to_exclude_expired){
206
-			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false,false);
207
-			if($non_expired){
204
+	public function get_primary_datetime_for_event($EVT_ID, $try_to_exclude_expired = true, $try_to_exclude_deleted = true) {
205
+		if ($try_to_exclude_expired) {
206
+			$non_expired = $this->get_oldest_datetime_for_event($EVT_ID, false, false);
207
+			if ($non_expired) {
208 208
 				return $non_expired;
209 209
 			}
210 210
 		}
211
-		if($try_to_exclude_deleted){
211
+		if ($try_to_exclude_deleted) {
212 212
 			$expired_even = $this->get_oldest_datetime_for_event($EVT_ID, true);
213
-			if($expired_even){
213
+			if ($expired_even) {
214 214
 				return $expired_even;
215 215
 			}
216 216
 		}
@@ -229,23 +229,23 @@  discard block
 block discarded – undo
229 229
 	 * @param int $limit
230 230
 	 * @return EE_Datetime[]
231 231
 	 */
232
-	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted= true, $limit = NULL ){
232
+	public function get_datetimes_for_event_ordered_by_start_time($EVT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
233 233
 		//sanitize EVT_ID
234
-		$EVT_ID = intval( $EVT_ID );
234
+		$EVT_ID = intval($EVT_ID);
235 235
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
236
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
237
-		$query_params =array(array('Event.EVT_ID'=>$EVT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
238
-		if( ! $include_expired){
239
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
236
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
237
+		$query_params = array(array('Event.EVT_ID'=>$EVT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
238
+		if ( ! $include_expired) {
239
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
240 240
 		}
241
-		if( $include_deleted){
242
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
241
+		if ($include_deleted) {
242
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
243 243
 		}
244
-		if($limit){
244
+		if ($limit) {
245 245
 			$query_params['limit'] = $limit;
246 246
 		}
247
-		$result = $this->get_all( $query_params );
248
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
247
+		$result = $this->get_all($query_params);
248
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
249 249
 		return $result;
250 250
 	}
251 251
 
@@ -258,23 +258,23 @@  discard block
 block discarded – undo
258 258
 	 * @param int $limit
259 259
 	 * @return EE_Datetime[]
260 260
 	 */
261
-	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted= true, $limit = NULL){
261
+	public function get_datetimes_for_ticket_ordered_by_start_time($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
262 262
 		//sanitize TKT_ID
263
-		$TKT_ID =  intval( $TKT_ID );
263
+		$TKT_ID = intval($TKT_ID);
264 264
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
265
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
266
-		$query_params =array(array('Ticket.TKT_ID'=>$TKT_ID),'order_by'=>array('DTT_EVT_start'=>'asc'));
267
-		if( ! $include_expired){
268
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
265
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
266
+		$query_params = array(array('Ticket.TKT_ID'=>$TKT_ID), 'order_by'=>array('DTT_EVT_start'=>'asc'));
267
+		if ( ! $include_expired) {
268
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
269 269
 		}
270
-		if( $include_deleted){
271
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
270
+		if ($include_deleted) {
271
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
272 272
 		}
273
-		if($limit){
273
+		if ($limit) {
274 274
 			$query_params['limit'] = $limit;
275 275
 		}
276
-		$result = $this->get_all( $query_params );
277
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
276
+		$result = $this->get_all($query_params);
277
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
278 278
 		return $result;
279 279
 	}
280 280
 
@@ -290,24 +290,24 @@  discard block
 block discarded – undo
290 290
 	 *                                  that number
291 291
 	 * @return EE_Datetime[]
292 292
 	 */
293
-	public function get_datetimes_for_ticket_ordered_by_DTT_order( $TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL ) {
293
+	public function get_datetimes_for_ticket_ordered_by_DTT_order($TKT_ID, $include_expired = true, $include_deleted = true, $limit = NULL) {
294 294
 		//sanitize id.
295
-		$TKT_ID =  intval( $TKT_ID );
295
+		$TKT_ID = intval($TKT_ID);
296 296
 		$old_assumption = $this->get_assumption_concerning_values_already_prepared_by_model_object();
297
-		$this->assume_values_already_prepared_by_model_object( EEM_Base::prepared_for_use_in_db );
298
-		$where_params = array( 'Ticket.TKT_ID' => $TKT_ID );
299
-		$query_params = array( $where_params, 'order_by' => array( 'DTT_order' => 'ASC' ) );
300
-		if( ! $include_expired){
301
-			$query_params[0]['DTT_EVT_end'] = array('>=',current_time('mysql', TRUE));
297
+		$this->assume_values_already_prepared_by_model_object(EEM_Base::prepared_for_use_in_db);
298
+		$where_params = array('Ticket.TKT_ID' => $TKT_ID);
299
+		$query_params = array($where_params, 'order_by' => array('DTT_order' => 'ASC'));
300
+		if ( ! $include_expired) {
301
+			$query_params[0]['DTT_EVT_end'] = array('>=', current_time('mysql', TRUE));
302 302
 		}
303
-		if( $include_deleted){
304
-			$query_params[0]['DTT_deleted'] = array('IN',array(true,false));
303
+		if ($include_deleted) {
304
+			$query_params[0]['DTT_deleted'] = array('IN', array(true, false));
305 305
 		}
306
-		if($limit){
306
+		if ($limit) {
307 307
 			$query_params['limit'] = $limit;
308 308
 		}
309
-		$result = $this->get_all( $query_params );
310
-		$this->assume_values_already_prepared_by_model_object( $old_assumption );
309
+		$result = $this->get_all($query_params);
310
+		$this->assume_values_already_prepared_by_model_object($old_assumption);
311 311
 		return $result;
312 312
 	}
313 313
 
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
 	 * @param int $EVT_ID
319 319
 	 * @return EE_Datetime
320 320
 	 */
321
-	public function get_most_important_datetime_for_event($EVT_ID){
321
+	public function get_most_important_datetime_for_event($EVT_ID) {
322 322
 		$results = $this->get_datetimes_for_event_ordered_by_importance($EVT_ID, 1);
323
-		if($results){
323
+		if ($results) {
324 324
 			return array_shift($results);
325
-		}else{
325
+		} else {
326 326
 			return null;
327 327
 		}
328 328
 	}
@@ -341,71 +341,71 @@  discard block
 block discarded – undo
341 341
 	 * 			- inactive = Events that are either not published.
342 342
 	 * @return wpdb results array
343 343
 	 */
344
-	public function get_dtt_months_and_years( $where_params, $evt_active_status = '' ) {
344
+	public function get_dtt_months_and_years($where_params, $evt_active_status = '') {
345 345
 
346
-		switch ( $evt_active_status ) {
346
+		switch ($evt_active_status) {
347 347
 			case 'upcoming' :
348 348
 					$where_params['Event.status'] = 'publish';
349 349
 					//if there are already query_params matching DTT_EVT_start then we need to modify that to add them.
350
-					if ( isset( $where_params['DTT_EVT_start'] ) ) {
350
+					if (isset($where_params['DTT_EVT_start'])) {
351 351
 						$where_params['DTT_EVT_start*****'] = $where_params['DTT_EVT_start'];
352 352
 					}
353
-					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query( 'DTT_EVT_start' ) );
353
+					$where_params['DTT_EVT_start'] = array('>', $this->current_time_for_query('DTT_EVT_start'));
354 354
 					break;
355 355
 
356 356
 			case 'expired' :
357
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
357
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
358 358
 				//get events to exclude
359
-				$exclude_query[0] = array_merge( $where_params, array( 'DTT_EVT_end' => array( '>', $this->current_time_for_query( 'DTT_EVT_end' ) ) ) );
359
+				$exclude_query[0] = array_merge($where_params, array('DTT_EVT_end' => array('>', $this->current_time_for_query('DTT_EVT_end'))));
360 360
 				//first get all events that have datetimes where its not expired.
361
-				$event_ids = $this->_get_all_wpdb_results( $exclude_query, OBJECT_K, 'Datetime.EVT_ID' );
362
-				$event_ids = array_keys( $event_ids );
361
+				$event_ids = $this->_get_all_wpdb_results($exclude_query, OBJECT_K, 'Datetime.EVT_ID');
362
+				$event_ids = array_keys($event_ids);
363 363
 
364
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
364
+				if (isset($where_params['DTT_EVT_end'])) {
365 365
 					$where_params['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
366 366
 				}
367
-				$where_params['DTT_EVT_end'] = array( '<', EEM_Datetime::instance()->current_time_for_query( 'DTT_EVT_end' ) );
368
-				$where_params['Event.EVT_ID'] = array( 'NOT IN', $event_ids );
367
+				$where_params['DTT_EVT_end'] = array('<', EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end'));
368
+				$where_params['Event.EVT_ID'] = array('NOT IN', $event_ids);
369 369
 				break;
370 370
 
371 371
 			case 'active' :
372 372
 				$where_params['Event.status'] = 'publish';
373
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
373
+				if (isset($where_params['DTT_EVT_start'])) {
374 374
 					$where_params['Datetime.DTT_EVT_start******'] = $where_params['DTT_EVT_start'];
375 375
 				}
376
-				if ( isset( $where_params['Datetime.DTT_EVT_end'] ) ) {
376
+				if (isset($where_params['Datetime.DTT_EVT_end'])) {
377 377
 					$where_params['Datetime.DTT_EVT_end*****'] = $where_params['DTT_EVT_end'];
378 378
 				}
379
-				$where_params['DTT_EVT_start'] = array('<',  $this->current_time_for_query( 'DTT_EVT_start' ) );
380
-				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query( 'DTT_EVT_end' ) );
379
+				$where_params['DTT_EVT_start'] = array('<', $this->current_time_for_query('DTT_EVT_start'));
380
+				$where_params['DTT_EVT_end'] = array('>', $this->current_time_for_query('DTT_EVT_end'));
381 381
 				break;
382 382
 
383 383
 			case 'inactive' :
384
-				if ( isset( $where_params['Event.status'] ) ) unset( $where_params['Event.status'] );
385
-				if ( isset( $where_params['OR'] ) ) {
384
+				if (isset($where_params['Event.status'])) unset($where_params['Event.status']);
385
+				if (isset($where_params['OR'])) {
386 386
 					$where_params['AND']['OR'] = $where_params['OR'];
387 387
 				}
388
-				if ( isset( $where_params['DTT_EVT_end'] ) ) {
388
+				if (isset($where_params['DTT_EVT_end'])) {
389 389
 					$where_params['AND']['DTT_EVT_end****'] = $where_params['DTT_EVT_end'];
390
-					unset( $where_params['DTT_EVT_end'] );
390
+					unset($where_params['DTT_EVT_end']);
391 391
 				}
392 392
 
393
-				if ( isset( $where_params['DTT_EVT_start'] ) ) {
393
+				if (isset($where_params['DTT_EVT_start'])) {
394 394
 					$where_params['AND']['DTT_EVT_start'] = $where_params['DTT_EVT_start'];
395
-					unset( $where_params['DTT_EVT_start'] );
395
+					unset($where_params['DTT_EVT_start']);
396 396
 				}
397
-				$where_params['AND']['Event.status'] = array( '!=', 'publish' );
397
+				$where_params['AND']['Event.status'] = array('!=', 'publish');
398 398
 				break;
399 399
 		}
400 400
 
401 401
 		$query_params[0] = $where_params;
402 402
 		$query_params['group_by'] = array('dtt_year', 'dtt_month');
403
-		$query_params['order_by'] = array( 'DTT_EVT_start' => 'DESC' );
403
+		$query_params['order_by'] = array('DTT_EVT_start' => 'DESC');
404 404
 		$columns_to_select = array(
405 405
 			'dtt_year' => array('YEAR(DTT_EVT_start)', '%s'),
406 406
 			'dtt_month' => array('MONTHNAME(DTT_EVT_start)', '%s')
407 407
 			);
408
-		return $this->_get_all_wpdb_results( $query_params, OBJECT, $columns_to_select );
408
+		return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select);
409 409
 	}
410 410
 
411 411
 	/**
@@ -413,8 +413,8 @@  discard block
 block discarded – undo
413 413
 	 * for the tickets for each datetime)
414 414
 	 * @param EE_Datetime[] $datetimes
415 415
 	 */
416
-	public function update_sold($datetimes){
417
-		foreach($datetimes as $datetime){
416
+	public function update_sold($datetimes) {
417
+		foreach ($datetimes as $datetime) {
418 418
 			$datetime->update_sold();
419 419
 		}
420 420
 	}
@@ -429,10 +429,10 @@  discard block
 block discarded – undo
429 429
 	 * @param array $query_params
430 430
 	 * @return int of tickets available. If sold out, return less than 1. If infinite, returns EE_INF,  IF there are NO tickets attached to datetime then FALSE is returned.
431 431
 	 */
432
-	public function sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params = array() ) {
433
-		$datetime = $this->get_one_by_ID( $DTT_ID );
434
-		if ( $datetime instanceof EE_Datetime ) {
435
-			return $datetime->tickets_remaining( $query_params );
432
+	public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) {
433
+		$datetime = $this->get_one_by_ID($DTT_ID);
434
+		if ($datetime instanceof EE_Datetime) {
435
+			return $datetime->tickets_remaining($query_params);
436 436
 		}
437 437
 		return 0;
438 438
 	}
@@ -454,36 +454,36 @@  discard block
 block discarded – undo
454 454
 	 *                EE_Datetime::upcoming
455 455
 	 *                EE_Datetime::expired
456 456
 	 */
457
-	public function get_datetime_counts_by_status( $stati_to_include = array(), $query_params = array() ) {
457
+	public function get_datetime_counts_by_status($stati_to_include = array(), $query_params = array()) {
458 458
 		//only accept where conditions for this query.
459
-		$_where = isset( $query_params[0] ) ? $query_params[0] : array();
459
+		$_where = isset($query_params[0]) ? $query_params[0] : array();
460 460
 		$status_query_args = array(
461 461
 				EE_Datetime::active => array_merge(
462 462
 						$_where,
463
-						array( 'DTT_EVT_start' => array( '<', time() ), 'DTT_EVT_end' => array( '>', time() ) )
463
+						array('DTT_EVT_start' => array('<', time()), 'DTT_EVT_end' => array('>', time()))
464 464
 				),
465 465
 				EE_Datetime::upcoming => array_merge(
466 466
 						$_where,
467
-						array( 'DTT_EVT_start' => array( '>', time() ) )
467
+						array('DTT_EVT_start' => array('>', time()))
468 468
 				),
469 469
 				EE_Datetime::expired => array_merge(
470 470
 						$_where,
471
-						array( 'DTT_EVT_end' => array('<', time() ) )
471
+						array('DTT_EVT_end' => array('<', time()))
472 472
 				)
473 473
 		);
474 474
 
475
-		if ( ! empty( $stati_to_include ) ) {
476
-			foreach( array_keys( $status_query_args ) as $status ) {
477
-				if ( ! in_array( $status, $stati_to_include ) ) {
478
-					unset( $status_query_args[$status] );
475
+		if ( ! empty($stati_to_include)) {
476
+			foreach (array_keys($status_query_args) as $status) {
477
+				if ( ! in_array($status, $stati_to_include)) {
478
+					unset($status_query_args[$status]);
479 479
 				}
480 480
 			}
481 481
 		}
482 482
 
483 483
 		//loop through and query counts for each stati.
484 484
 		$status_query_results = array();
485
-		foreach( $status_query_args as $status => $status_where_conditions ) {
486
-			$status_query_results[ $status ] = EEM_Datetime::count( array( $status_where_conditions ), 'DTT_ID', true );
485
+		foreach ($status_query_args as $status => $status_where_conditions) {
486
+			$status_query_results[$status] = EEM_Datetime::count(array($status_where_conditions), 'DTT_ID', true);
487 487
 		}
488 488
 
489 489
 		return $status_query_results;
@@ -497,9 +497,9 @@  discard block
 block discarded – undo
497 497
 	 * @param array $query_params
498 498
 	 * @return int
499 499
 	 */
500
-	public function get_datetime_count_for_status( $status = EE_Datetime::active, $query_params = array() ) {
501
-		$count = $this->get_datetime_counts_by_status( array( $status ), $query_params );
502
-		return ! empty( $count[$status] ) ? $count[$status] : 0;
500
+	public function get_datetime_count_for_status($status = EE_Datetime::active, $query_params = array()) {
501
+		$count = $this->get_datetime_counts_by_status(array($status), $query_params);
502
+		return ! empty($count[$status]) ? $count[$status] : 0;
503 503
 	}
504 504
 
505 505
 
Please login to merge, or discard this patch.
core/db_models/EEM_Line_Item.model.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -103,41 +103,41 @@  discard block
 block discarded – undo
103 103
 	 * @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)
104 104
 	 * @return \EEM_Line_Item
105 105
 	 */
106
-	protected function __construct( $timezone ) {
107
-		$this->singular_item = __('Line Item','event_espresso');
108
-		$this->plural_item = __('Line Items','event_espresso');
106
+	protected function __construct($timezone) {
107
+		$this->singular_item = __('Line Item', 'event_espresso');
108
+		$this->plural_item = __('Line Items', 'event_espresso');
109 109
 
110 110
 		$this->_tables = array(
111
-			'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID')
111
+			'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID')
112 112
 		);
113
-		$line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) );
113
+		$line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event'));
114 114
 		$this->_fields = array(
115 115
 			'Line_Item' => array(
116
-				'LIN_ID' 				=> new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ),
117
-				'LIN_code' 			=> new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ),
118
-				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ),
119
-				'LIN_name' 			=> new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ),
120
-				'LIN_desc' 			=> new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ),
121
-				'LIN_unit_price' 	=> new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ),
122
-				'LIN_percent' 		=> new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ),
123
-				'LIN_is_taxable' 	=> new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ),
124
-				'LIN_order' 			=> new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ),
125
-				'LIN_total' 			=> new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ),
126
-				'LIN_quantity' 	=> new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ),
127
-				'LIN_parent' 		=> new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ),
128
-				'LIN_type' 			=> new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array(
116
+				'LIN_ID' 				=> new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")),
117
+				'LIN_code' 			=> new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE),
118
+				'TXN_ID' 				=> new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'),
119
+				'LIN_name' 			=> new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''),
120
+				'LIN_desc' 			=> new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE),
121
+				'LIN_unit_price' 	=> new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0),
122
+				'LIN_percent' 		=> new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0),
123
+				'LIN_is_taxable' 	=> new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE),
124
+				'LIN_order' 			=> new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1),
125
+				'LIN_total' 			=> new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0),
126
+				'LIN_quantity' 	=> new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1),
127
+				'LIN_parent' 		=> new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL),
128
+				'LIN_type' 			=> new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array(
129 129
 						self::type_line_item		=>  __("Line Item", "event_espresso"),
130 130
 						self::type_sub_line_item	=>  __("Sub-Item", "event_espresso"),
131 131
 						self::type_sub_total		=>  __("Subtotal", "event_espresso"),
132 132
 						self::type_tax_sub_total 	=> __("Tax Subtotal", "event_espresso"),
133 133
 						self::type_tax					=>  __("Tax", "event_espresso"),
134 134
 						self::type_total				=>  __("Total", "event_espresso"),
135
-						self::type_cancellation	=> __( 'Cancellation', 'event_espresso' )
135
+						self::type_cancellation	=> __('Cancellation', 'event_espresso')
136 136
 					)
137 137
 				),
138
-				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ),
139
-				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ),
140
-				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, time(), $timezone ),
138
+				'OBJ_ID' 					=> new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for),
139
+				'OBJ_type'				=>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for),
140
+				'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, time(), $timezone),
141 141
 			)
142 142
 		);
143 143
 		$this->_model_relations = array(
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 		);
149 149
 		$this->_model_chain_to_wp_user = 'Transaction.Registration.Event';
150 150
 		$this->_caps_slug = 'transactions';
151
-		parent::__construct( $timezone );
151
+		parent::__construct($timezone);
152 152
 	}
153 153
 
154 154
 
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
 	 * @param EE_Transaction|int $transaction
160 160
 	 * @return EE_Line_Item[]
161 161
 	 */
162
-	public function get_all_of_type_for_transaction( $line_item_type, $transaction ){
163
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
164
-		return $this->get_all( array( array(
162
+	public function get_all_of_type_for_transaction($line_item_type, $transaction) {
163
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
164
+		return $this->get_all(array(array(
165 165
 			'LIN_type' => $line_item_type,
166 166
 			'TXN_ID' => $transaction
167 167
 		)));
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 	 * @param EE_Transaction|int $transaction
176 176
 	 * @return \EE_Base_Class[]
177 177
 	 */
178
-	public function get_all_non_ticket_line_items_for_transaction( $transaction ) {
179
-		$transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction );
180
-		return $this->get_all( array( array(
178
+	public function get_all_non_ticket_line_items_for_transaction($transaction) {
179
+		$transaction = EEM_Transaction::instance()->ensure_is_ID($transaction);
180
+		return $this->get_all(array(array(
181 181
 			'LIN_type' => self::type_line_item,
182 182
 			'TXN_ID' => $transaction,
183 183
 			'OR' => array(
184
-				'OBJ_type*notticket' => array( '!=', 'Ticket'),
185
-				'OBJ_type*null' => array( 'IS_NULL' ))
184
+				'OBJ_type*notticket' => array('!=', 'Ticket'),
185
+				'OBJ_type*null' => array('IS_NULL'))
186 186
 		)));
187 187
 	}
188 188
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 * because if there are spam bots afoot there will be LOTS of line items
193 193
 	 * @return int count of how many deleted
194 194
 	 */
195
-	public function delete_line_items_with_no_transaction(){
195
+	public function delete_line_items_with_no_transaction() {
196 196
 		/** @type WPDB $wpdb */
197 197
 		global $wpdb;
198 198
 		$time_to_leave_alone = apply_filters(
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 		);
201 201
 		$query = $wpdb->prepare(
202 202
 				'DELETE li
203
-				FROM ' . $this->table() . ' li
204
-				LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID
203
+				FROM ' . $this->table().' li
204
+				LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID
205 205
 				WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s',
206 206
 				// use GMT time because that's what TXN_timestamps are in
207
-				gmdate(  'Y-m-d H:i:s', time() - $time_to_leave_alone )
207
+				gmdate('Y-m-d H:i:s', time() - $time_to_leave_alone)
208 208
 				);
209
-		return $wpdb->query( $query );
209
+		return $wpdb->query($query);
210 210
 	}
211 211
 
212 212
 
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	 * @param \EE_Base_Class $object
220 220
 	 * @return EE_Line_Item[]
221 221
 	 */
222
-	public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){
223
-		return $this->get_all( array( array(
222
+	public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) {
223
+		return $this->get_all(array(array(
224 224
 			'TXN_ID' 		=> $TXN_ID,
225
-			'OBJ_type' 	=> str_replace( 'EE_', '', get_class( $object )),
225
+			'OBJ_type' 	=> str_replace('EE_', '', get_class($object)),
226 226
 			'OBJ_ID' 		=> $object->ID()
227 227
 		)));
228 228
 	}
@@ -238,16 +238,16 @@  discard block
 block discarded – undo
238 238
 	 * @param array $OBJ_IDs
239 239
 	 * @return EE_Line_Item[]
240 240
 	 */
241
-	public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){
241
+	public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) {
242 242
 		$query_params = array(
243 243
 			'OBJ_type' 	=> $OBJ_type,
244 244
 			// if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query
245
-			'OBJ_ID' 		=> is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs
245
+			'OBJ_ID' 		=> is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs
246 246
 		);
247
-		if ( $TXN_ID ) {
247
+		if ($TXN_ID) {
248 248
 			$query_params['TXN_ID'] = $TXN_ID;
249 249
 		}
250
-		return $this->get_all( array( $query_params ));
250
+		return $this->get_all(array($query_params));
251 251
 	}
252 252
 
253 253
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * @param EE_Promotion $promotion
263 263
 	 * @return EE_Line_Item
264 264
 	 */
265
-	public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) {
266
-		return $this->get_one( array(
265
+	public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) {
266
+		return $this->get_one(array(
267 267
 			array(
268 268
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
269 269
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 	 * @param EE_Line_Item $parent_line_item
285 285
 	 * @return EE_Line_Item[]
286 286
 	 */
287
-	public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) {
288
-		return $this->get_all( array(
287
+	public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) {
288
+		return $this->get_all(array(
289 289
 			array(
290 290
 				'TXN_ID' 			=> $parent_line_item->TXN_ID(),
291 291
 				'LIN_parent' 	=> $parent_line_item->ID(),
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param EE_Registration $registration
303 303
 	 * @return EEM_Line_ITem
304 304
 	 */
305
-	public function get_line_item_for_registration( EE_Registration $registration ) {
306
-		return $this->get_one( $this->line_item_for_registration_query_params( $registration ));
305
+	public function get_line_item_for_registration(EE_Registration $registration) {
306
+		return $this->get_one($this->line_item_for_registration_query_params($registration));
307 307
 	}
308 308
 
309 309
 	/**
@@ -312,14 +312,14 @@  discard block
 block discarded – undo
312 312
 	 * @param array $original_query_params any extra query params you'd like to be merged with
313 313
 	 * @return array like EEM_Base::get_all()'s $query_params
314 314
 	 */
315
-	public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) {
316
-		return array_replace_recursive( $original_query_params, array(
315
+	public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) {
316
+		return array_replace_recursive($original_query_params, array(
317 317
 			array(
318 318
 				'OBJ_ID' => $registration->ticket_ID(),
319 319
 				'OBJ_type' => 'Ticket',
320 320
 				'TXN_ID' => $registration->transaction_ID()
321 321
 			)
322
-		) );
322
+		));
323 323
 	}
324 324
 
325 325
 
Please login to merge, or discard this patch.
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
2 2
 /**
3
- * Event Espresso
4
- *
5
- * Event Registration and Management Plugin for WordPress
6
- *
7
- * @ package			Event Espresso
8
- * @ author				Seth Shoultes
9
- * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
- * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
- * @ link					http://www.eventespresso.com
12
- * @ version		 	4.0
13
- *
14
- * ------------------------------------------------------------------------
15
- *
16
- * Line Item Model. Mostly used for storing a snapshot of all the items in a transaction
17
- * as they were recorded at the time of being added to the cart.
18
- * There are different 'types' of line items: item, sub-item, tax, sub-total, and total.
19
- * Note that line items can be nested. For example, a total line item should have one-or-more
20
- * children sub-totals. Likewise, sub-totals should have one-or-more nested items or taxes
21
- * (or maybe promotions or products?). Also, items can have nested sub-items (eg. an item could be a
22
- * ticket, which has many sub-item prices which together make up the price of that ticket).
23
- * Note that line items should point to real model objects using OBJ_ID and OBJ_type (note:
24
- * there is a current limitation that they can only point to models with INT primary keys),
25
- * but this is NOT required. And in fact, the items they are related to CAN be deleted, but
26
- * the line item should still exist (in this case it merely shows that there was ONCE a model
27
- * object the line item was based off of).
28
- *
29
- * In usage, Line Items are first stored on the EE_Cart, but not saved until a user's registration is
30
- * finalized (like how the EE_Transaction is stored in the session until it is confirmed).
31
- * Many of their methods (like
32
- *
33
- *
34
- * @package			Event Espresso
35
- * @subpackage		includes/models/EEM_Line_Item.model.php
36
- * @author			Mike Nelson
37
- *
38
- * ------------------------------------------------------------------------
39
- */
3
+	 * Event Espresso
4
+	 *
5
+	 * Event Registration and Management Plugin for WordPress
6
+	 *
7
+	 * @ package			Event Espresso
8
+	 * @ author				Seth Shoultes
9
+	 * @ copyright		(c) 2008-2011 Event Espresso  All Rights Reserved.
10
+	 * @ license			http://eventespresso.com/support/terms-conditions/   * see Plugin Licensing *
11
+	 * @ link					http://www.eventespresso.com
12
+	 * @ version		 	4.0
13
+	 *
14
+	 * ------------------------------------------------------------------------
15
+	 *
16
+	 * Line Item Model. Mostly used for storing a snapshot of all the items in a transaction
17
+	 * as they were recorded at the time of being added to the cart.
18
+	 * There are different 'types' of line items: item, sub-item, tax, sub-total, and total.
19
+	 * Note that line items can be nested. For example, a total line item should have one-or-more
20
+	 * children sub-totals. Likewise, sub-totals should have one-or-more nested items or taxes
21
+	 * (or maybe promotions or products?). Also, items can have nested sub-items (eg. an item could be a
22
+	 * ticket, which has many sub-item prices which together make up the price of that ticket).
23
+	 * Note that line items should point to real model objects using OBJ_ID and OBJ_type (note:
24
+	 * there is a current limitation that they can only point to models with INT primary keys),
25
+	 * but this is NOT required. And in fact, the items they are related to CAN be deleted, but
26
+	 * the line item should still exist (in this case it merely shows that there was ONCE a model
27
+	 * object the line item was based off of).
28
+	 *
29
+	 * In usage, Line Items are first stored on the EE_Cart, but not saved until a user's registration is
30
+	 * finalized (like how the EE_Transaction is stored in the session until it is confirmed).
31
+	 * Many of their methods (like
32
+	 *
33
+	 *
34
+	 * @package			Event Espresso
35
+	 * @subpackage		includes/models/EEM_Line_Item.model.php
36
+	 * @author			Mike Nelson
37
+	 *
38
+	 * ------------------------------------------------------------------------
39
+	 */
40 40
 
41 41
 class EEM_Line_Item extends EEM_Base {
42 42
 
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Option.model.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once( EE_CLASSES . 'EE_Question_Option.class.php');
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once(EE_CLASSES.'EE_Question_Option.class.php');
26 26
 
27 27
 
28 28
 class EEM_Question_Option extends EEM_Soft_Delete_Base {
@@ -30,22 +30,22 @@  discard block
 block discarded – undo
30 30
   	// private instance of the Attendee object
31 31
 	protected static $_instance = NULL;
32 32
 
33
-	protected function __construct( $timezone = NULL ) {
34
-		$this->singular_item = __('Question Option','event_espresso');
35
-		$this->plural_item = __('Question Options','event_espresso');
33
+	protected function __construct($timezone = NULL) {
34
+		$this->singular_item = __('Question Option', 'event_espresso');
35
+		$this->plural_item = __('Question Options', 'event_espresso');
36 36
 
37 37
 		$this->_tables = array(
38
-			'Question_Option'=>new EE_Primary_Table('esp_question_option','QSO_ID')
38
+			'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID')
39 39
 		);
40 40
 		$this->_fields = array(
41 41
 			'Question_Option'=>array(
42
-					'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID','event_espresso')),
43
-					'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'),
44
-					'QSO_value'=>new EE_Plain_Text_Field('QSO_value',  __("Question Option Value", "event_espresso"),false,''),
45
-					'QSO_desc'=>new EE_Full_HTML_Field('QSO_desc', __('Question Option Description','event_espresso'), false, ''),
46
-					'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso' ), false, 0 ),
47
-					'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option','event_espresso'), TRUE, NULL ),
48
-					'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed','event_espresso'), false, false)
42
+					'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')),
43
+					'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'),
44
+					'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''),
45
+					'QSO_desc'=>new EE_Full_HTML_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''),
46
+					'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0),
47
+					'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), TRUE, NULL),
48
+					'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false)
49 49
 				)
50 50
 		);
51 51
 		$this->_model_relations = array(
@@ -54,12 +54,12 @@  discard block
 block discarded – undo
54 54
 
55 55
 		$this->_model_chain_to_wp_user = 'Question';
56 56
 		//this model is generally available for reading
57
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
58
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Option');
59
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Option');
60
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Option');
57
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
58
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('Question_Option');
59
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('Question_Option');
60
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('Question_Option');
61 61
 		$this->_caps_slug = 'questions';
62
-		parent::__construct( $timezone );
62
+		parent::__construct($timezone);
63 63
 	}
64 64
 
65 65
 
Please login to merge, or discard this patch.
core/db_models/EEM_System_Status.model.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -215,17 +215,17 @@
 block discarded – undo
215 215
 	 * Whether or not a .maintenance file is detected
216 216
 	 * @return string descripting wp_maintenance_mode status
217 217
 	 */
218
-    function get_wp_maintenance_mode() {
219
-        $opened = file_exists( ABSPATH . '.maintenance' );
220
-        return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
221
-    }
218
+	function get_wp_maintenance_mode() {
219
+		$opened = file_exists( ABSPATH . '.maintenance' );
220
+		return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
221
+	}
222 222
 	/**
223 223
 	 * Whether or not logging is enabled
224 224
 	 * @return string descripting logging's status
225 225
 	 */
226 226
 	function get_logging_enabled(){
227
-            $opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
-            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
227
+			$opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
+			return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
229 229
 	}
230 230
 	/**
231 231
 	 *  Whether curl ro fsock works
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Model for retrieving Information about the Event Espresso status.
5 5
  */
6
-class EEM_System_Status{
6
+class EEM_System_Status {
7 7
 
8 8
 	// private instance of the EEM_System_Status object
9 9
 	protected static $_instance = NULL;
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		}
27 27
 		return self::$_instance;
28 28
 	}
29
-	private function __construct(){
29
+	private function __construct() {
30 30
 
31 31
 	}
32 32
 	/**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	 * @return array where each key is a function name on this class, and each value is SOMETHING--
35 35
 	 * it might be a value, an array, or an object
36 36
 	 */
37
-	function get_system_stati(){
37
+	function get_system_stati() {
38 38
 		return array(
39 39
 				'ee_version'=>$this->get_ee_version(),
40 40
 				'ee_activation_history'=>$this->get_ee_activation_history(),
@@ -55,14 +55,14 @@  discard block
 block discarded – undo
55 55
 	 *
56 56
 	 * @return string
57 57
 	 */
58
-	function get_ee_version(){
58
+	function get_ee_version() {
59 59
 		return espresso_version();
60 60
 	}
61 61
 	/**
62 62
 	 *
63 63
 	 * @return string
64 64
 	 */
65
-	function php_version(){
65
+	function php_version() {
66 66
 		return phpversion();
67 67
 	}
68 68
 	/**
@@ -79,16 +79,16 @@  discard block
 block discarded – undo
79 79
 		'DomainPath' => 'Domain Path',
80 80
 		'Network' => 'Network',
81 81
 	 */
82
-	function get_active_plugins(){
83
-		$active_plugins = (array) get_option( 'active_plugins', array() );
84
-		if ( is_multisite() )
85
-			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
86
-		$active_plugins = array_map( 'strtolower', $active_plugins );
82
+	function get_active_plugins() {
83
+		$active_plugins = (array) get_option('active_plugins', array());
84
+		if (is_multisite())
85
+			$active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
86
+		$active_plugins = array_map('strtolower', $active_plugins);
87 87
 		$plugin_info = array();
88
-		foreach ( $active_plugins as $plugin ) {
89
-				$plugin_data = @get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin );
88
+		foreach ($active_plugins as $plugin) {
89
+				$plugin_data = @get_plugin_data(WP_PLUGIN_DIR.'/'.$plugin);
90 90
 
91
-				$plugin_info[ $plugin ] = $plugin_data;
91
+				$plugin_info[$plugin] = $plugin_data;
92 92
 		}
93 93
 		return $plugin_info;
94 94
 	}
@@ -97,17 +97,17 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return array with keys 'home_url' and 'site_url'
99 99
 	 */
100
-	function get_wp_settings(){
101
-		$wp_memory_int = $this->let_to_num( WP_MEMORY_LIMIT );
102
-		if ( $wp_memory_int < 67108864 ) {
103
-			$wp_memory_to_display = '<mark class="error">' . sprintf( __('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"' ) . '</mark>';
100
+	function get_wp_settings() {
101
+		$wp_memory_int = $this->let_to_num(WP_MEMORY_LIMIT);
102
+		if ($wp_memory_int < 67108864) {
103
+			$wp_memory_to_display = '<mark class="error">'.sprintf(__('%s - We recommend setting memory to at least 64MB. See: %s Increasing memory allocated to PHP %s', 'event_espresso'), WP_MEMORY_LIMIT, '<a href="http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP">', '</a>"').'</mark>';
104 104
 		} else {
105
-			$wp_memory_to_display = '<mark class="yes">' . size_format( $wp_memory_int ) . '</mark>';
105
+			$wp_memory_to_display = '<mark class="yes">'.size_format($wp_memory_int).'</mark>';
106 106
 		}
107 107
 		return array(
108
-			'name'=>get_bloginfo('name','display'),
108
+			'name'=>get_bloginfo('name', 'display'),
109 109
 			'is_multisite'=>is_multisite(),
110
-			'version'=>  get_bloginfo( 'version', 'display' ),
110
+			'version'=>  get_bloginfo('version', 'display'),
111 111
 			'home_url'=>home_url(),
112 112
 			'site_url'=>site_url(),
113 113
 			'WP_DEBUG'=>WP_DEBUG,
@@ -116,8 +116,8 @@  discard block
 block discarded – undo
116 116
 			'gmt_offset'=>get_option('gmt_offset'),
117 117
 			'timezone_string'=>get_option('timezone_string'),
118 118
 			'admin_email'=>  get_bloginfo('admin_email', 'display'),
119
-			'language'=>get_bloginfo('language','display'),
120
-			'wp_max_upload_size' => size_format( wp_max_upload_size() ),
119
+			'language'=>get_bloginfo('language', 'display'),
120
+			'wp_max_upload_size' => size_format(wp_max_upload_size()),
121 121
 			'wp_memory' => $wp_memory_to_display
122 122
 			);
123 123
 	}
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * Gets an array of information about the history of ee versions installed
127 127
 	 * @return array
128 128
 	 */
129
-	function get_ee_activation_history(){
129
+	function get_ee_activation_history() {
130 130
 		return get_option('espresso_db_update');
131 131
 	}
132 132
 
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 * Gets an array where keys are ee versions, and their values are arrays indicating all the different times that version was installed
136 136
 	 * @return EE_Data_Migration_Script_Base[]
137 137
 	 */
138
-	function get_ee_migration_history(){
138
+	function get_ee_migration_history() {
139 139
 		$options = EE_Data_Migration_Manager::instance()->get_all_migration_script_options();
140 140
 		$presentable_migration_scripts = array();
141
-		foreach($options as $option_array){
142
-			$presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix,"",$option_array['option_name'])] = maybe_unserialize($option_array['option_value']);
141
+		foreach ($options as $option_array) {
142
+			$presentable_migration_scripts[str_replace(EE_Data_Migration_Manager::data_migration_script_option_prefix, "", $option_array['option_name'])] = maybe_unserialize($option_array['option_value']);
143 143
 		}
144 144
 		return $presentable_migration_scripts;
145 145
 //		return get_option(EE_Data_Migration_Manager::data_migrations_option_name);//EE_Data_Migration_Manager::instance()->get_data_migrations_ran();
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return array like EE_Config class
151 151
 	 */
152
-	function get_ee_config(){
152
+	function get_ee_config() {
153 153
 		return EE_Config::instance();
154 154
 	}
155 155
 
@@ -157,24 +157,24 @@  discard block
 block discarded – undo
157 157
 	 * Gets an array of php setup info, pilfered from http://www.php.net/manual/en/function.phpinfo.php#87463
158 158
 	 * @return array like the output of phpinfo(), but in an array
159 159
 	 */
160
-	function get_php_info(){
160
+	function get_php_info() {
161 161
 		ob_start();
162 162
 		phpinfo(-1);
163 163
 
164 164
 		$pi = preg_replace(
165 165
 		array('#^.*<body>(.*)</body>.*$#ms', '#<h2>PHP License</h2>.*$#ms',
166
-		'#<h1>Configuration</h1>#',  "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
166
+		'#<h1>Configuration</h1>#', "#\r?\n#", "#</(h1|h2|h3|tr)>#", '# +<#',
167 167
 		"#[ \t]+#", '#&nbsp;#', '#  +#', '# class=".*?"#', '%&#039;%',
168 168
 		 '#<tr>(?:.*?)" src="(?:.*?)=(.*?)" alt="PHP Logo" /></a>'
169 169
 		 .'<h1>PHP Version (.*?)</h1>(?:\n+?)</td></tr>#',
170 170
 		 '#<h1><a href="(?:.*?)\?=(.*?)">PHP Credits</a></h1>#',
171 171
 		 '#<tr>(?:.*?)" src="(?:.*?)=(.*?)"(?:.*?)Zend Engine (.*?),(?:.*?)</tr>#',
172 172
 		 "# +#", '#<tr>#', '#</tr>#'),
173
-		array('$1', '', '', '', '</$1>' . "\n", '<', ' ', ' ', ' ', '', ' ',
173
+		array('$1', '', '', '', '</$1>'."\n", '<', ' ', ' ', ' ', '', ' ',
174 174
 		 '<h2>PHP Configuration</h2>'."\n".'<tr><td>PHP Version</td><td>$2</td></tr>'.
175 175
 		 "\n".'<tr><td>PHP Egg</td><td>$1</td></tr>',
176 176
 		 '<tr><td>PHP Credits Egg</td><td>$1</td></tr>',
177
-		 '<tr><td>Zend Engine</td><td>$2</td></tr>' . "\n" .
177
+		 '<tr><td>Zend Engine</td><td>$2</td></tr>'."\n".
178 178
 		 '<tr><td>Zend Egg</td><td>$1</td></tr>', ' ', '%S%', '%E%'),
179 179
 		ob_get_clean());
180 180
 
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 		unset($sections[0]);
183 183
 
184 184
 		$pi = array();
185
-		foreach($sections as $section){
185
+		foreach ($sections as $section) {
186 186
 		  $n = substr($section, 0, strpos($section, '</h2>'));
187 187
 		  preg_match_all(
188 188
 		  '#%S%(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?(?:<td>(.*?)</td>)?%E%#',
189 189
 			$section, $askapache, PREG_SET_ORDER);
190
-		  foreach($askapache as $m)
190
+		  foreach ($askapache as $m)
191 191
 			  $m2 = isset($m[2]) ? $m[2] : null;
192
-			  $pi[$n][$m[1]]=(!isset($m[3])||$m2==$m[3]) ? $m2 : array_slice($m,2);
192
+			  $pi[$n][$m[1]] = ( ! isset($m[3]) || $m2 == $m[3]) ? $m2 : array_slice($m, 2);
193 193
 		}
194 194
 
195 195
 		return $pi;
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
 	 * Checks if site responds ot HTTPS
200 200
 	 * @return boolean
201 201
 	 */
202
-	function get_https_enabled(){
202
+	function get_https_enabled() {
203 203
 		$home = str_replace("http://", "https://", home_url());
204 204
 		$response = wp_remote_get($home);
205
-		if($response instanceof WP_Error){
205
+		if ($response instanceof WP_Error) {
206 206
 			$error_string = '';
207
-			foreach($response->errors as $short_name => $description_array){
208
-				$error_string .= "<b>$short_name</b>: ".implode(", ",$description_array);
207
+			foreach ($response->errors as $short_name => $description_array) {
208
+				$error_string .= "<b>$short_name</b>: ".implode(", ", $description_array);
209 209
 			}
210 210
 			return $error_string;
211 211
 		}
@@ -216,32 +216,32 @@  discard block
 block discarded – undo
216 216
 	 * @return string descripting wp_maintenance_mode status
217 217
 	 */
218 218
     function get_wp_maintenance_mode() {
219
-        $opened = file_exists( ABSPATH . '.maintenance' );
220
-        return $opened ? sprintf( __('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>','</strong>' ) : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso')  ;
219
+        $opened = file_exists(ABSPATH.'.maintenance');
220
+        return $opened ? sprintf(__('%s.maintenance file detected.%s Wordpress may have a failed auto-update which could prevent Event Espresso from updating the database correctly.', 'event_espresso'), '<strong>', '</strong>') : __('.maintenance file not detected. WordPress is not in maintenance mode.', 'event_espresso');
221 221
     }
222 222
 	/**
223 223
 	 * Whether or not logging is enabled
224 224
 	 * @return string descripting logging's status
225 225
 	 */
226
-	function get_logging_enabled(){
227
-            $opened = @fopen( EVENT_ESPRESSO_UPLOAD_DIR . '/logs/espresso_log.txt', 'a' );
228
-            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf( __('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"','</mark>' ) ;
226
+	function get_logging_enabled() {
227
+            $opened = @fopen(EVENT_ESPRESSO_UPLOAD_DIR.'/logs/espresso_log.txt', 'a');
228
+            return $opened ? __('Log Directory is writable', 'event_espresso') : sprintf(__('%sLog directory is NOT writable%s', 'event_espresso'), '<mark class="error"', '</mark>');
229 229
 	}
230 230
 	/**
231 231
 	 *  Whether curl ro fsock works
232 232
 	 * @return string describing posting's status
233 233
 	 */
234
-	function get_remote_posting(){
235
-		$fsock_works = function_exists( 'fsockopen' );
236
-		$curl_works = function_exists( 'curl_init' );
237
-		if ( $fsock_works && $curl_works ) {
234
+	function get_remote_posting() {
235
+		$fsock_works = function_exists('fsockopen');
236
+		$curl_works = function_exists('curl_init');
237
+		if ($fsock_works && $curl_works) {
238 238
 			$status = __('Your server has fsockopen and cURL enabled.', 'event_espresso');
239
-		} elseif ( $fsock_works ) {
239
+		} elseif ($fsock_works) {
240 240
 			$status = __('Your server has fsockopen enabled, cURL is disabled.', 'event_espresso');
241
-		} elseif( $curl_works ) {
241
+		} elseif ($curl_works) {
242 242
 			$status = __('Your server has cURL enabled, fsockopen is disabled.', 'event_espresso');
243
-		}else{
244
-			$status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso'). '</mark>';
243
+		} else {
244
+			$status = __('Your server does not have fsockopen or cURL enabled - PayPal IPN and other scripts which communicate with other servers will not work. Contact your hosting provider.', 'event_espresso').'</mark>';
245 245
 		}
246 246
 		return $status;
247 247
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 * Gets all the php.ini settings
251 251
 	 * @return array
252 252
 	 */
253
-	function get_php_ini_all(){
253
+	function get_php_ini_all() {
254 254
 		return ini_get_all();
255 255
 	}
256 256
 	/**
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
 	 * @param type $size
260 260
 	 * @return int
261 261
 	 */
262
-	function let_to_num( $size ) {
263
-		$l 		= substr( $size, -1 );
264
-		$ret 	= substr( $size, 0, -1 );
265
-		switch( strtoupper( $l ) ) {
262
+	function let_to_num($size) {
263
+		$l = substr($size, -1);
264
+		$ret = substr($size, 0, -1);
265
+		switch (strtoupper($l)) {
266 266
 			case 'P':
267 267
 				$ret *= 1024;
268 268
 			case 'T':
Please login to merge, or discard this patch.
core/db_models/EEM_Term_Relationship.model.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -21,61 +21,61 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
24
+require_once (EE_MODELS.'EEM_Base.model.php');
25 25
 
26 26
 class EEM_Term_Relationship extends EEM_Base {
27 27
 
28 28
   	// private instance of the Attendee object
29 29
 	protected static $_instance = NULL;
30 30
 
31
-	protected function __construct( $timezone = NULL ) {
32
-		$this->singular_item = __('Term Relationship','event_espresso');
33
-		$this->plural_item = __('Term Relationships','event_espresso');
31
+	protected function __construct($timezone = NULL) {
32
+		$this->singular_item = __('Term Relationship', 'event_espresso');
33
+		$this->plural_item = __('Term Relationships', 'event_espresso');
34 34
 		$this->_tables = array(
35 35
 			'Term_Relationship'=> new EE_Primary_Table('term_relationships')
36 36
 		);
37
-		$models_this_can_attach_to = array_keys( EE_Registry::instance()->cpt_models() );
37
+		$models_this_can_attach_to = array_keys(EE_Registry::instance()->cpt_models());
38 38
 		$this->_fields = array(
39 39
 			'Term_Relationship'=>array(
40
-				'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID','event_espresso'), false,0, $models_this_can_attach_to ),
41
-				'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'),
42
-				'term_order'=>new EE_Integer_Field('term_order', __('Term Order','event_espresso'), false, 0)
40
+				'object_id'=> new EE_Foreign_Key_Int_Field('object_id', __('Object(Post) ID', 'event_espresso'), false, 0, $models_this_can_attach_to),
41
+				'term_taxonomy_id'=>new EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID', 'event_espresso'), false, 0, 'Term_Taxonomy'),
42
+				'term_order'=>new EE_Integer_Field('term_order', __('Term Order', 'event_espresso'), false, 0)
43 43
 			));
44 44
 		$this->_model_relations = array(
45 45
 			'Term_Taxonomy'=>new EE_Belongs_To_Relation()
46 46
 		);
47
-		foreach( $models_this_can_attach_to as $model_name ) {
48
-			$this->_model_relations[ $model_name ] = new EE_Belongs_To_Relation();
47
+		foreach ($models_this_can_attach_to as $model_name) {
48
+			$this->_model_relations[$model_name] = new EE_Belongs_To_Relation();
49 49
 		}
50 50
 		$this->_indexes = array(
51
-			'PRIMARY'=>new EE_Primary_Key_Index(array('object_id','term_taxonomy_id'))
51
+			'PRIMARY'=>new EE_Primary_Key_Index(array('object_id', 'term_taxonomy_id'))
52 52
 		);
53 53
 		$path_to_event_model = 'Event.';
54
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Event_Related_Public( $path_to_event_model );
55
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model );
56
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model );
57
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Event_Related_Protected( $path_to_event_model, EEM_Base::caps_edit );
54
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Event_Related_Public($path_to_event_model);
55
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model);
56
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model);
57
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Event_Related_Protected($path_to_event_model, EEM_Base::caps_edit);
58 58
 
59 59
 		$path_to_tax_model = 'Term_Taxonomy.';
60 60
 		//add cap restrictions for editing term relations to the "ee_assign_*"
61 61
 		//and for deleting term relations too
62
-		$cap_contexts_affected = array( EEM_Base::caps_edit, EEM_Base::caps_delete );
63
-		foreach( $cap_contexts_affected as $cap_context_affected ) {
64
-			$this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_category'] = new EE_Default_Where_Conditions(
62
+		$cap_contexts_affected = array(EEM_Base::caps_edit, EEM_Base::caps_delete);
63
+		foreach ($cap_contexts_affected as $cap_context_affected) {
64
+			$this->_cap_restrictions[$cap_context_affected]['ee_assign_event_category'] = new EE_Default_Where_Conditions(
65 65
 					array(
66
-						$path_to_tax_model . 'taxonomy*ee_assign_event_category' => array( '!=', 'espresso_event_categories' )
66
+						$path_to_tax_model.'taxonomy*ee_assign_event_category' => array('!=', 'espresso_event_categories')
67 67
 					));
68
-			$this->_cap_restrictions[ $cap_context_affected ]['ee_assign_venue_category'] = new EE_Default_Where_Conditions(
68
+			$this->_cap_restrictions[$cap_context_affected]['ee_assign_venue_category'] = new EE_Default_Where_Conditions(
69 69
 					array(
70
-						$path_to_tax_model . 'taxonomy*ee_assign_venue_category' => array( '!=', 'espresso_venue_categories' )
70
+						$path_to_tax_model.'taxonomy*ee_assign_venue_category' => array('!=', 'espresso_venue_categories')
71 71
 					));
72
-			$this->_cap_restrictions[ $cap_context_affected ]['ee_assign_event_type'] = new EE_Default_Where_Conditions(
72
+			$this->_cap_restrictions[$cap_context_affected]['ee_assign_event_type'] = new EE_Default_Where_Conditions(
73 73
 					array(
74
-						$path_to_tax_model . 'taxonomy*ee_assign_event_type' => array( '!=', 'espresso_event_type' )
74
+						$path_to_tax_model.'taxonomy*ee_assign_event_type' => array('!=', 'espresso_event_type')
75 75
 					));
76 76
 		}
77 77
 
78
-		parent::__construct( $timezone );
78
+		parent::__construct($timezone);
79 79
 	}
80 80
 
81 81
 	/**
@@ -84,17 +84,17 @@  discard block
 block discarded – undo
84 84
 	 * @global type $wpdb
85 85
 	 * @return int the number of rows affected
86 86
 	 */
87
-	public function update_term_taxonomy_counts($term_taxonomy_id = NULL){
87
+	public function update_term_taxonomy_counts($term_taxonomy_id = NULL) {
88 88
 		//because this uses a subquery and sometimes assigning to column to be another column's
89 89
 		//value, we just write the SQL directly.
90 90
 		global $wpdb;
91
-		if( $term_taxonomy_id ){
92
-			$second_operand = $wpdb->prepare('%d',$term_taxonomy_id);
93
-		}else{
91
+		if ($term_taxonomy_id) {
92
+			$second_operand = $wpdb->prepare('%d', $term_taxonomy_id);
93
+		} else {
94 94
 			$second_operand = 'tr.term_taxonomy_id';
95 95
 		}
96
-		$rows_affected = $this->_do_wpdb_query( 'query' , array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count
97
-from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)" ) );
96
+		$rows_affected = $this->_do_wpdb_query('query', array("UPDATE {$wpdb->term_taxonomy} AS tt SET count = (select count(*) as proper_count
97
+from {$wpdb->term_relationships} AS tr WHERE tt.term_taxonomy_id = $second_operand)"));
98 98
 		return $rows_affected;
99 99
 	}
100 100
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	public function insert($field_n_values) {
108 108
 		$return = parent::insert($field_n_values);
109
-		if( isset( $field_n_values[ 'term_taxonomy_id' ] ) ) {
110
-			$this->update_term_taxonomy_counts($field_n_values[ 'term_taxonomy_id' ] );
109
+		if (isset($field_n_values['term_taxonomy_id'])) {
110
+			$this->update_term_taxonomy_counts($field_n_values['term_taxonomy_id']);
111 111
 		}
112 112
 		return $return;
113 113
 	}
@@ -123,8 +123,8 @@  discard block
 block discarded – undo
123 123
 	 * @return int
124 124
 	 */
125 125
 	public function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
126
-		$count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync );
127
-		if( $count ){
126
+		$count = parent::update($fields_n_values, $query_params, $keep_model_objs_in_sync);
127
+		if ($count) {
128 128
 			$this->update_term_taxonomy_counts();
129 129
 		}
130 130
 		return $count;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function delete($query_params, $allow_blocking = true) {
140 140
 		$count = parent::delete($query_params, $allow_blocking);
141
-		if( $count ){
141
+		if ($count) {
142 142
 			$this->update_term_taxonomy_counts();
143 143
 		}
144 144
 		return $count;
Please login to merge, or discard this patch.
core/db_models/EEM_Term_Taxonomy.model.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
24
+require_once (EE_MODELS.'EEM_Base.model.php');
25 25
 
26 26
 class EEM_Term_Taxonomy extends EEM_Base {
27 27
 
@@ -29,67 +29,67 @@  discard block
 block discarded – undo
29 29
 	protected static $_instance = NULL;
30 30
 
31 31
 
32
-	protected function __construct( $timezone = NULL ) {
33
-		$this->singular_item = __('Term Taxonomy','event_espresso');
34
-		$this->plural_item = __('Term Taxonomy','event_espresso');
32
+	protected function __construct($timezone = NULL) {
33
+		$this->singular_item = __('Term Taxonomy', 'event_espresso');
34
+		$this->plural_item = __('Term Taxonomy', 'event_espresso');
35 35
 		$this->_tables = array(
36 36
 			'Term_Taxonomy'=> new EE_Primary_Table('term_taxonomy', 'term_taxonomy_id')
37 37
 		);
38 38
 		$this->_fields = array(
39 39
 			'Term_Taxonomy'=>array(
40
-				'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID','event_espresso')),
41
-				'term_id'=>new EE_Foreign_Key_Int_Field('term_id',  __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'),
42
-				'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name','event_espresso'), false, 'category'),
43
-				'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false,''),
44
-				'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false,0),
40
+				'term_taxonomy_id'=> new EE_Primary_Key_Int_Field('term_taxonomy_id', __('Term-Taxonomy ID', 'event_espresso')),
41
+				'term_id'=>new EE_Foreign_Key_Int_Field('term_id', __("Term Id", "event_espresso"), false, 0, 'Term'), //EE_Foreign_Key_Int_Field('term_taxonomy_id', __('Term (in context of a taxonomy) ID','event_espresso'), false, 0, 'Term_Taxonomy'),
42
+				'taxonomy'=>new EE_Plain_Text_Field('taxonomy', __('Taxonomy Name', 'event_espresso'), false, 'category'),
43
+				'description'=>new EE_Post_Content_Field('description', __("Description of Term", "event_espresso"), false, ''),
44
+				'parent'=>new EE_Integer_Field('parent', __("Parent Term ID", "event_espresso"), false, 0),
45 45
 				'term_count'=> new EE_Integer_Field('count', __("Count of Objects attached", 'event_espresso'), false, 0)
46 46
 			));
47 47
 		$this->_model_relations = array(
48 48
 			'Term_Relationship'=>new EE_Has_Many_Relation(),
49 49
 			'Term'=>new EE_Belongs_To_Relation(),
50 50
 		);
51
-		$cpt_models = array_keys( EE_Registry::instance()->cpt_models() );
52
-		foreach( $cpt_models  as $model_name ) {
53
-			$this->_model_relations[ $model_name ] = new EE_HABTM_Relation( 'Term_Relationship' );
51
+		$cpt_models = array_keys(EE_Registry::instance()->cpt_models());
52
+		foreach ($cpt_models  as $model_name) {
53
+			$this->_model_relations[$model_name] = new EE_HABTM_Relation('Term_Relationship');
54 54
 		}
55 55
 		$this->_indexes = array(
56
-			'term_id_taxonomy'=>new EE_Unique_Index(array('term_id','taxonomy'))
56
+			'term_id_taxonomy'=>new EE_Unique_Index(array('term_id', 'taxonomy'))
57 57
 		);
58 58
 		$path_to_tax_model = '';
59
-		$this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public();
60
-		$this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Taxonomy_Protected( $path_to_tax_model );
61
-		$this->_cap_restriction_generators[ EEM_Base::caps_edit ] = false;
62
-		$this->_cap_restriction_generators[ EEM_Base::caps_delete ] = false;
59
+		$this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public();
60
+		$this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Taxonomy_Protected($path_to_tax_model);
61
+		$this->_cap_restriction_generators[EEM_Base::caps_edit] = false;
62
+		$this->_cap_restriction_generators[EEM_Base::caps_delete] = false;
63 63
 
64 64
 		//add cap restrictions for editing relating to the "ee_edit_*"
65
-		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
65
+		$this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_category'] = new EE_Default_Where_Conditions(
66 66
 				array(
67
-					$path_to_tax_model . 'taxonomy*ee_edit_event_category' => array( '!=', 'espresso_event_categories' )
67
+					$path_to_tax_model.'taxonomy*ee_edit_event_category' => array('!=', 'espresso_event_categories')
68 68
 				));
69
-		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
69
+		$this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_venue_category'] = new EE_Default_Where_Conditions(
70 70
 				array(
71
-					$path_to_tax_model . 'taxonomy*ee_edit_venue_category' => array( '!=', 'espresso_venue_categories' )
71
+					$path_to_tax_model.'taxonomy*ee_edit_venue_category' => array('!=', 'espresso_venue_categories')
72 72
 				));
73
-		$this->_cap_restrictions[ EEM_Base::caps_edit ]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
73
+		$this->_cap_restrictions[EEM_Base::caps_edit]['ee_edit_event_type'] = new EE_Default_Where_Conditions(
74 74
 				array(
75
-					$path_to_tax_model . 'taxonomy*ee_edit_event_type' => array( '!=', 'espresso_event_type' )
75
+					$path_to_tax_model.'taxonomy*ee_edit_event_type' => array('!=', 'espresso_event_type')
76 76
 				));
77 77
 
78 78
 		//add cap restrictions for deleting relating to the "ee_deleting_*"
79
-		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
79
+		$this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_category'] = new EE_Default_Where_Conditions(
80 80
 				array(
81
-					$path_to_tax_model . 'taxonomy*ee_delete_event_category' => array( '!=', 'espresso_event_categories' )
81
+					$path_to_tax_model.'taxonomy*ee_delete_event_category' => array('!=', 'espresso_event_categories')
82 82
 				));
83
-		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
83
+		$this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_venue_category'] = new EE_Default_Where_Conditions(
84 84
 				array(
85
-					$path_to_tax_model . 'taxonomy*ee_delete_venue_category' => array( '!=', 'espresso_venue_categories' )
85
+					$path_to_tax_model.'taxonomy*ee_delete_venue_category' => array('!=', 'espresso_venue_categories')
86 86
 				));
87
-		$this->_cap_restrictions[ EEM_Base::caps_delete ]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
87
+		$this->_cap_restrictions[EEM_Base::caps_delete]['ee_delete_event_type'] = new EE_Default_Where_Conditions(
88 88
 				array(
89
-					$path_to_tax_model . 'taxonomy*ee_delete_event_type' => array( '!=', 'espresso_event_type' )
89
+					$path_to_tax_model.'taxonomy*ee_delete_event_type' => array('!=', 'espresso_event_type')
90 90
 				));
91 91
 
92
-		parent::__construct( $timezone );
92
+		parent::__construct($timezone);
93 93
 	}
94 94
 
95 95
 }
Please login to merge, or discard this patch.
core/db_models/fields/EE_Enum_Text_Field.php 1 patch
Spacing   +11 added lines, -11 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
 	}
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
 	 * @return string
38 38
 	 * @throws EE_Error
39 39
 	 */
40
-	function prepare_for_set( $value_inputted_for_field_on_model_object ) {
41
-		if(
40
+	function prepare_for_set($value_inputted_for_field_on_model_object) {
41
+		if (
42 42
 			$value_inputted_for_field_on_model_object !== null
43
-			&& ! array_key_exists( $value_inputted_for_field_on_model_object, $this->_allowed_enum_values )
44
-		){
45
-			if( defined( 'WP_DEBUG' ) &&  WP_DEBUG ){
43
+			&& ! array_key_exists($value_inputted_for_field_on_model_object, $this->_allowed_enum_values)
44
+		) {
45
+			if (defined('WP_DEBUG') && WP_DEBUG) {
46 46
 				$msg = sprintf(
47
-					__('System is assigning incompatible value "%1$s" to field "%2$s"','event_espresso'),
47
+					__('System is assigning incompatible value "%1$s" to field "%2$s"', 'event_espresso'),
48 48
 					$value_inputted_for_field_on_model_object,
49 49
 					$this->_name
50 50
 				);
51 51
 				$msg2 = sprintf(
52
-					__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"','event_espresso'),
52
+					__('Allowed values for "%1$s" are "%2$s". You provided: "%3$s"', 'event_espresso'),
53 53
 					$this->_name,
54
-					implode( ", ", array_keys( $this->_allowed_enum_values ) ),
54
+					implode(", ", array_keys($this->_allowed_enum_values)),
55 55
 					$value_inputted_for_field_on_model_object
56 56
 				);
57
-				EE_Error::add_error( "$msg||$msg2", __FILE__, __FUNCTION__, __LINE__ );
57
+				EE_Error::add_error("$msg||$msg2", __FILE__, __FUNCTION__, __LINE__);
58 58
 			}
59 59
 			return $this->get_default_value();
60 60
 
Please login to merge, or discard this patch.
core/db_models/fields/EE_Serialized_Text_Field.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
  * However, when inserting into the DB, it should be serialized.
8 8
  * Upon retrieval from the DB, it should be unserialized back into an array.
9 9
  */
10
-require_once( EE_MODELS . 'fields/EE_Text_Field_Base.php' );
11
-class EE_Serialized_Text_Field extends EE_Text_Field_Base{
10
+require_once(EE_MODELS.'fields/EE_Text_Field_Base.php');
11
+class EE_Serialized_Text_Field extends EE_Text_Field_Base {
12 12
 	/**
13 13
 	 * Value SHOULD be an array, and we want to now convert it to a serialized string
14 14
 	 * @param array $value_of_field_on_model_object
@@ -18,13 +18,13 @@  discard block
 block discarded – undo
18 18
 		return maybe_serialize($value_of_field_on_model_object);
19 19
 	}
20 20
 	function prepare_for_set($value_inputted_for_field_on_model_object) {
21
-		EE_Registry::instance()->load_helper( 'Array' );
22
-		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize( $value_inputted_for_field_on_model_object );
23
-		if(is_string($value_inputted_for_field_on_model_object)){
21
+		EE_Registry::instance()->load_helper('Array');
22
+		$value_inputted_for_field_on_model_object = EEH_Array::maybe_unserialize($value_inputted_for_field_on_model_object);
23
+		if (is_string($value_inputted_for_field_on_model_object)) {
24 24
 			return parent::prepare_for_set($value_inputted_for_field_on_model_object);
25
-		}elseif(is_array($value_inputted_for_field_on_model_object)){
26
-			return array_map(array($this,'prepare_for_set'), $value_inputted_for_field_on_model_object);
27
-		}else{//so they passed NULL or an INT or something wack
25
+		}elseif (is_array($value_inputted_for_field_on_model_object)) {
26
+			return array_map(array($this, 'prepare_for_set'), $value_inputted_for_field_on_model_object);
27
+		} else {//so they passed NULL or an INT or something wack
28 28
 			return $value_inputted_for_field_on_model_object;
29 29
 		}
30 30
 	}
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 	 * @return array
35 35
 	 */
36 36
 	function prepare_for_set_from_db($value_found_in_db_for_model_object) {
37
-		EE_Registry::instance()->load_helper( 'Array' );
38
-		return EEH_Array::maybe_unserialize( $value_found_in_db_for_model_object );
37
+		EE_Registry::instance()->load_helper('Array');
38
+		return EEH_Array::maybe_unserialize($value_found_in_db_for_model_object);
39 39
 	}
40 40
 
41 41
 	/**
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
 	 * @return string
46 46
 	 */
47 47
 	function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) {
48
-		switch($schema){
48
+		switch ($schema) {
49 49
 			case 'print_r':
50
-				$pretty_value = print_r($value_on_field_to_be_outputted,true);
50
+				$pretty_value = print_r($value_on_field_to_be_outputted, true);
51 51
 				break;
52 52
 			case 'as_table':
53 53
 				EE_Registry::instance()->load_helper('Template');
54 54
 				$pretty_value = EEH_Template::layout_array_as_table($value_on_field_to_be_outputted);
55 55
 				break;
56 56
 			default:
57
-				$pretty_value = implode(", ",$value_on_field_to_be_outputted);
57
+				$pretty_value = implode(", ", $value_on_field_to_be_outputted);
58 58
 		}
59 59
 		return $pretty_value;
60 60
 	}
Please login to merge, or discard this patch.