@@ -1,5 +1,5 @@ discard block |
||
| 1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 2 | - exit( 'No direct script access allowed' ); |
|
| 1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 2 | + exit('No direct script access allowed'); |
|
| 3 | 3 | } |
| 4 | 4 | /** |
| 5 | 5 | * Event Espresso |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | * date_format and the second value is the time format |
| 38 | 38 | * @return EE_Question |
| 39 | 39 | */ |
| 40 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
| 41 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
| 42 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
| 40 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
| 41 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
| 42 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -50,8 +50,8 @@ discard block |
||
| 50 | 50 | * the website will be used. |
| 51 | 51 | * @return EE_Question |
| 52 | 52 | */ |
| 53 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
| 54 | - return new self( $props_n_values, TRUE, $timezone ); |
|
| 53 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
| 54 | + return new self($props_n_values, TRUE, $timezone); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | * @access public |
| 63 | 63 | * @param string $QST_display_text |
| 64 | 64 | */ |
| 65 | - public function set_display_text( $QST_display_text = '' ) { |
|
| 66 | - $this->set( 'QST_display_text', $QST_display_text ); |
|
| 65 | + public function set_display_text($QST_display_text = '') { |
|
| 66 | + $this->set('QST_display_text', $QST_display_text); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @access public |
| 75 | 75 | * @param string $QST_admin_label |
| 76 | 76 | */ |
| 77 | - public function set_admin_label( $QST_admin_label = '' ) { |
|
| 78 | - $this->set( 'QST_admin_label', $QST_admin_label ); |
|
| 77 | + public function set_admin_label($QST_admin_label = '') { |
|
| 78 | + $this->set('QST_admin_label', $QST_admin_label); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | * @access public |
| 87 | 87 | * @param mixed $QST_system |
| 88 | 88 | */ |
| 89 | - public function set_system_ID( $QST_system = '' ) { |
|
| 90 | - $this->set( 'QST_system', $QST_system ); |
|
| 89 | + public function set_system_ID($QST_system = '') { |
|
| 90 | + $this->set('QST_system', $QST_system); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | * @access public |
| 99 | 99 | * @param string $QST_type |
| 100 | 100 | */ |
| 101 | - public function set_question_type( $QST_type = '' ) { |
|
| 102 | - $this->set( 'QST_type', $QST_type ); |
|
| 101 | + public function set_question_type($QST_type = '') { |
|
| 102 | + $this->set('QST_type', $QST_type); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
| 110 | 110 | * @access public |
| 111 | 111 | * @param bool $QST_required |
| 112 | 112 | */ |
| 113 | - public function set_required( $QST_required = FALSE ) { |
|
| 114 | - $this->set( 'QST_required', $QST_required ); |
|
| 113 | + public function set_required($QST_required = FALSE) { |
|
| 114 | + $this->set('QST_required', $QST_required); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | * @access public |
| 123 | 123 | * @param string $QST_required_text |
| 124 | 124 | */ |
| 125 | - public function set_required_text( $QST_required_text = '' ) { |
|
| 126 | - $this->set( 'QST_required_text', $QST_required_text ); |
|
| 125 | + public function set_required_text($QST_required_text = '') { |
|
| 126 | + $this->set('QST_required_text', $QST_required_text); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @access public |
| 135 | 135 | * @param int $QST_order |
| 136 | 136 | */ |
| 137 | - public function set_order( $QST_order = 0 ) { |
|
| 138 | - $this->set( 'QST_order', $QST_order ); |
|
| 137 | + public function set_order($QST_order = 0) { |
|
| 138 | + $this->set('QST_order', $QST_order); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | * @access public |
| 147 | 147 | * @param bool $QST_admin_only |
| 148 | 148 | */ |
| 149 | - public function set_admin_only( $QST_admin_only = FALSE ) { |
|
| 150 | - $this->set( 'QST_admin_only', $QST_admin_only ); |
|
| 149 | + public function set_admin_only($QST_admin_only = FALSE) { |
|
| 150 | + $this->set('QST_admin_only', $QST_admin_only); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | * @access public |
| 159 | 159 | * @param int $QST_wp_user |
| 160 | 160 | */ |
| 161 | - public function set_wp_user( $QST_wp_user = 1 ) { |
|
| 162 | - $this->set( 'QST_wp_user', $QST_wp_user ); |
|
| 161 | + public function set_wp_user($QST_wp_user = 1) { |
|
| 162 | + $this->set('QST_wp_user', $QST_wp_user); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
@@ -175,8 +175,8 @@ discard block |
||
| 175 | 175 | * @access public |
| 176 | 176 | * @param bool $QST_deleted |
| 177 | 177 | */ |
| 178 | - public function set_deleted( $QST_deleted = FALSE ) { |
|
| 179 | - $this->set( 'QST_deleted', $QST_deleted ); |
|
| 178 | + public function set_deleted($QST_deleted = FALSE) { |
|
| 179 | + $this->set('QST_deleted', $QST_deleted); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * @return string |
| 188 | 188 | */ |
| 189 | 189 | public function display_text() { |
| 190 | - return $this->get( 'QST_display_text' ); |
|
| 190 | + return $this->get('QST_display_text'); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @return string |
| 199 | 199 | */ |
| 200 | 200 | public function admin_label() { |
| 201 | - return $this->get( 'QST_admin_label' ); |
|
| 201 | + return $this->get('QST_admin_label'); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @return string |
| 210 | 210 | */ |
| 211 | 211 | public function system_ID() { |
| 212 | - return $this->get( 'QST_system' ); |
|
| 212 | + return $this->get('QST_system'); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | * @return boolean |
| 221 | 221 | */ |
| 222 | 222 | public function required() { |
| 223 | - return $this->get( 'QST_required' ); |
|
| 223 | + return $this->get('QST_required'); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | 234 | public function required_text() { |
| 235 | - return $this->get( 'QST_required_text' ); |
|
| 235 | + return $this->get('QST_required_text'); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | * @return string |
| 244 | 244 | */ |
| 245 | 245 | public function type() { |
| 246 | - return $this->get( 'QST_type' ); |
|
| 246 | + return $this->get('QST_type'); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @return int |
| 256 | 256 | */ |
| 257 | 257 | public function order() { |
| 258 | - return $this->get( 'QST_order' ); |
|
| 258 | + return $this->get('QST_order'); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * @return boolean |
| 268 | 268 | */ |
| 269 | 269 | public function admin_only() { |
| 270 | - return $this->get( 'QST_admin_only' ); |
|
| 270 | + return $this->get('QST_admin_only'); |
|
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * @return int |
| 279 | 279 | */ |
| 280 | 280 | public function wp_user() { |
| 281 | - return $this->get( 'QST_wp_user' ); |
|
| 281 | + return $this->get('QST_wp_user'); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * @return boolean |
| 290 | 290 | */ |
| 291 | 291 | public function deleted() { |
| 292 | - return $this->get( 'QST_deleted' ); |
|
| 292 | + return $this->get('QST_deleted'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | * @return EE_Answer[] |
| 300 | 300 | */ |
| 301 | 301 | public function answers() { |
| 302 | - return $this->get_many_related( 'Answer' ); |
|
| 302 | + return $this->get_many_related('Answer'); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | * @return boolean true = has answers, false = no answers. |
| 310 | 310 | */ |
| 311 | 311 | public function has_answers() { |
| 312 | - return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE; |
|
| 312 | + return $this->count_related('Answer') > 0 ? TRUE : FALSE; |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * @return EE_Question_Group[] |
| 320 | 320 | */ |
| 321 | 321 | public function question_groups() { |
| 322 | - return $this->get_many_related( 'Question_Group' ); |
|
| 322 | + return $this->get_many_related('Question_Group'); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
@@ -333,24 +333,24 @@ discard block |
||
| 333 | 333 | * whether it was trashed or not. |
| 334 | 334 | * @return EE_Question_Option[] |
| 335 | 335 | */ |
| 336 | - public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) { |
|
| 337 | - if ( ! $this->ID() ) { |
|
| 336 | + public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) { |
|
| 337 | + if ( ! $this->ID()) { |
|
| 338 | 338 | return array(); |
| 339 | 339 | } |
| 340 | 340 | $query_params = array(); |
| 341 | - if ( $selected_value_to_always_include ) { |
|
| 342 | - if ( is_array( $selected_value_to_always_include ) ) { |
|
| 343 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include ); |
|
| 341 | + if ($selected_value_to_always_include) { |
|
| 342 | + if (is_array($selected_value_to_always_include)) { |
|
| 343 | + $query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include); |
|
| 344 | 344 | } else { |
| 345 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include; |
|
| 345 | + $query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include; |
|
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | - if ( $notDeletedOptionsOnly ) { |
|
| 349 | - $query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE; |
|
| 348 | + if ($notDeletedOptionsOnly) { |
|
| 349 | + $query_params[0]['OR*options-query']['QSO_deleted'] = FALSE; |
|
| 350 | 350 | } |
| 351 | 351 | //order by QSO_order |
| 352 | - $query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' ); |
|
| 353 | - return $this->get_many_related( 'Question_Option', $query_params ); |
|
| 352 | + $query_params['order_by'] = array('QSO_order' => 'ASC'); |
|
| 353 | + return $this->get_many_related('Question_Option', $query_params); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | * @return \EE_Question_Option[] |
| 361 | 361 | */ |
| 362 | 362 | public function temp_options() { |
| 363 | - return $this->_model_relations[ 'Question_Option' ]; |
|
| 363 | + return $this->_model_relations['Question_Option']; |
|
| 364 | 364 | } |
| 365 | 365 | |
| 366 | 366 | |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @param EE_Question_Option $option |
| 372 | 372 | * @return boolean success |
| 373 | 373 | */ |
| 374 | - public function add_option( EE_Question_Option $option ) { |
|
| 375 | - return $this->_add_relation_to( $option, 'Question_Option' ); |
|
| 374 | + public function add_option(EE_Question_Option $option) { |
|
| 375 | + return $this->_add_relation_to($option, 'Question_Option'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -382,8 +382,8 @@ discard block |
||
| 382 | 382 | * @param EE_Question_Option $option |
| 383 | 383 | * @return boolean success |
| 384 | 384 | */ |
| 385 | - public function add_temp_option( EE_Question_Option $option ) { |
|
| 386 | - $this->_model_relations[ 'Question_Option' ][ ] = $option; |
|
| 385 | + public function add_temp_option(EE_Question_Option $option) { |
|
| 386 | + $this->_model_relations['Question_Option'][] = $option; |
|
| 387 | 387 | return TRUE; |
| 388 | 388 | } |
| 389 | 389 | |
@@ -394,8 +394,8 @@ discard block |
||
| 394 | 394 | * @param EE_Question_Option $option |
| 395 | 395 | * @return boolean success |
| 396 | 396 | */ |
| 397 | - public function remove_option( EE_Question_Option $option ) { |
|
| 398 | - return $this->_remove_relation_to( $option, 'Question_Option' ); |
|
| 397 | + public function remove_option(EE_Question_Option $option) { |
|
| 398 | + return $this->_remove_relation_to($option, 'Question_Option'); |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | |
@@ -404,8 +404,8 @@ discard block |
||
| 404 | 404 | * @return bool |
| 405 | 405 | */ |
| 406 | 406 | public function is_system_question() { |
| 407 | - $system_ID = $this->get( 'QST_system' ); |
|
| 408 | - return ! empty( $system_ID ) ? TRUE : FALSE; |
|
| 407 | + $system_ID = $this->get('QST_system'); |
|
| 408 | + return ! empty($system_ID) ? TRUE : FALSE; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | */ |
| 419 | 419 | public function set_order_to_latest() { |
| 420 | 420 | $latest_order = $this->get_model()->get_latest_question_order(); |
| 421 | - $latest_order ++; |
|
| 422 | - $this->set( 'QST_order', $latest_order ); |
|
| 421 | + $latest_order++; |
|
| 422 | + $this->set('QST_order', $latest_order); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -438,20 +438,20 @@ discard block |
||
| 438 | 438 | * Duplicates this question and its question options |
| 439 | 439 | * @return \EE_Question |
| 440 | 440 | */ |
| 441 | - public function duplicate( $options = array() ) { |
|
| 441 | + public function duplicate($options = array()) { |
|
| 442 | 442 | $new_question = clone $this; |
| 443 | - $new_question->set( 'QST_ID', null ); |
|
| 444 | - $new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) ); |
|
| 445 | - $new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) ); |
|
| 446 | - $new_question->set_system_ID( null ); |
|
| 447 | - $new_question->set_wp_user( get_current_user_id() ); |
|
| 443 | + $new_question->set('QST_ID', null); |
|
| 444 | + $new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text())); |
|
| 445 | + $new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label())); |
|
| 446 | + $new_question->set_system_ID(null); |
|
| 447 | + $new_question->set_wp_user(get_current_user_id()); |
|
| 448 | 448 | //if we're duplicating a trashed question, assume we don't want the new one to be trashed |
| 449 | - $new_question->set_deleted( false ); |
|
| 449 | + $new_question->set_deleted(false); |
|
| 450 | 450 | $success = $new_question->save(); |
| 451 | - if( $success ) { |
|
| 451 | + if ($success) { |
|
| 452 | 452 | //we don't totally want to duplicate the question options, because we want them to be for the NEW question |
| 453 | - foreach( $this->options() as $question_option ) { |
|
| 454 | - $question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) ); |
|
| 453 | + foreach ($this->options() as $question_option) { |
|
| 454 | + $question_option->duplicate(array('QST_ID' => $new_question->ID())); |
|
| 455 | 455 | } |
| 456 | 456 | return $new_question; |
| 457 | 457 | } else { |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | * @return int|float |
| 465 | 465 | */ |
| 466 | 466 | public function max() { |
| 467 | - return $this->get( 'QST_max' ); |
|
| 467 | + return $this->get('QST_max'); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | /** |
@@ -472,8 +472,8 @@ discard block |
||
| 472 | 472 | * @param int|float $new_max |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function set_max( $new_max ) { |
|
| 476 | - $this->set( 'QST_max', $new_max ); |
|
| 475 | + public function set_max($new_max) { |
|
| 476 | + $this->set('QST_max', $new_max); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | * @param array $input_constructor_args |
| 486 | 486 | * @return EE_Form_Input_Base |
| 487 | 487 | */ |
| 488 | - public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) { |
|
| 488 | + public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) { |
|
| 489 | 489 | $identifier = $this->is_system_question() ? $this->system_ID() : $this->ID(); |
| 490 | 490 | |
| 491 | 491 | $input_constructor_args = array_merge( |
@@ -496,27 +496,27 @@ discard block |
||
| 496 | 496 | ), |
| 497 | 497 | $input_constructor_args |
| 498 | 498 | ); |
| 499 | - if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) { |
|
| 500 | - $answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() ); |
|
| 499 | + if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) { |
|
| 500 | + $answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID()); |
|
| 501 | 501 | } |
| 502 | 502 | // has this question been answered ? |
| 503 | - if ( $answer instanceof EE_Answer ) { |
|
| 503 | + if ($answer instanceof EE_Answer) { |
|
| 504 | 504 | //answer gets htmlspecialchars called on it, undo that please |
| 505 | 505 | //beceause the form input's display strategy may call esc_attr too |
| 506 | 506 | //which also does html special characters |
| 507 | 507 | $values_with_html_special_chars = $answer->value(); |
| 508 | - if( is_array( $values_with_html_special_chars ) ) { |
|
| 509 | - $default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars ); |
|
| 508 | + if (is_array($values_with_html_special_chars)) { |
|
| 509 | + $default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars); |
|
| 510 | 510 | } else { |
| 511 | - $default_value = htmlspecialchars_decode( $values_with_html_special_chars ); |
|
| 511 | + $default_value = htmlspecialchars_decode($values_with_html_special_chars); |
|
| 512 | 512 | } |
| 513 | 513 | $input_constructor_args['default'] = $default_value; |
| 514 | 514 | } |
| 515 | - $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() ); |
|
| 516 | - if( EEM_Question::instance()->question_type_is_in_category( $this->type(), 'text' ) ) { |
|
| 517 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy( |
|
| 515 | + $max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID()); |
|
| 516 | + if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) { |
|
| 517 | + $input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy( |
|
| 518 | 518 | null, |
| 519 | - min( $max_max_for_question, $this->max() ) |
|
| 519 | + min($max_max_for_question, $this->max()) |
|
| 520 | 520 | ); |
| 521 | 521 | } |
| 522 | 522 | $input_constructor_args = apply_filters( |
@@ -528,22 +528,22 @@ discard block |
||
| 528 | 528 | ); |
| 529 | 529 | |
| 530 | 530 | $result = null; |
| 531 | - switch ( $this->type() ) { |
|
| 531 | + switch ($this->type()) { |
|
| 532 | 532 | // Text |
| 533 | 533 | case EEM_Question::QST_type_text : |
| 534 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 534 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 535 | 535 | break; |
| 536 | 536 | // Textarea |
| 537 | 537 | case EEM_Question::QST_type_textarea : |
| 538 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
| 538 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 539 | 539 | break; |
| 540 | 540 | // Radio Buttons |
| 541 | 541 | case EEM_Question::QST_type_radio : |
| 542 | - $result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args ); |
|
| 542 | + $result = new EE_Radio_Button_Input($this->options(), $input_constructor_args); |
|
| 543 | 543 | break; |
| 544 | 544 | // Dropdown |
| 545 | 545 | case EEM_Question::QST_type_dropdown : |
| 546 | - $result = new EE_Select_Input( $this->options(), $input_constructor_args ); |
|
| 546 | + $result = new EE_Select_Input($this->options(), $input_constructor_args); |
|
| 547 | 547 | break; |
| 548 | 548 | // State Dropdown |
| 549 | 549 | case EEM_Question::QST_type_state : |
@@ -554,7 +554,7 @@ discard block |
||
| 554 | 554 | $registration, |
| 555 | 555 | $answer |
| 556 | 556 | ); |
| 557 | - $result = new EE_State_Select_Input( $state_options, $input_constructor_args ); |
|
| 557 | + $result = new EE_State_Select_Input($state_options, $input_constructor_args); |
|
| 558 | 558 | break; |
| 559 | 559 | // Country Dropdown |
| 560 | 560 | case EEM_Question::QST_type_country : |
@@ -565,49 +565,49 @@ discard block |
||
| 565 | 565 | $registration, |
| 566 | 566 | $answer |
| 567 | 567 | ); |
| 568 | - $result = new EE_Country_Select_Input( $country_options, $input_constructor_args ); |
|
| 568 | + $result = new EE_Country_Select_Input($country_options, $input_constructor_args); |
|
| 569 | 569 | break; |
| 570 | 570 | // Checkboxes |
| 571 | 571 | case EEM_Question::QST_type_checkbox : |
| 572 | - $result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args ); |
|
| 572 | + $result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args); |
|
| 573 | 573 | break; |
| 574 | 574 | // Date |
| 575 | 575 | case EEM_Question::QST_type_date : |
| 576 | - $result = new EE_Datepicker_Input( $input_constructor_args ); |
|
| 576 | + $result = new EE_Datepicker_Input($input_constructor_args); |
|
| 577 | 577 | break; |
| 578 | 578 | case EEM_Question::QST_type_html_textarea : |
| 579 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 580 | - $result = new EE_Text_Area_Input( $input_constructor_args ); |
|
| 581 | - $result->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' ); |
|
| 579 | + $input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy(); |
|
| 580 | + $result = new EE_Text_Area_Input($input_constructor_args); |
|
| 581 | + $result->remove_validation_strategy('EE_Plaintext_Validation_Strategy'); |
|
| 582 | 582 | break; |
| 583 | 583 | case EEM_Question::QST_type_email : |
| 584 | - $result = new EE_Email_Input( $input_constructor_args ); |
|
| 584 | + $result = new EE_Email_Input($input_constructor_args); |
|
| 585 | 585 | break; |
| 586 | 586 | case EEM_Question::QST_type_us_phone : |
| 587 | - $result = new EE_Phone_Input( $input_constructor_args ); |
|
| 587 | + $result = new EE_Phone_Input($input_constructor_args); |
|
| 588 | 588 | break; |
| 589 | 589 | case EEM_Question::QST_type_int : |
| 590 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Int_Validation_Strategy(); |
|
| 591 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 590 | + $input_constructor_args['validation_strategies'][] = new EE_Int_Validation_Strategy(); |
|
| 591 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 592 | 592 | break; |
| 593 | 593 | case EEM_Question::QST_type_decimal : |
| 594 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_Float_Validation_Strategy(); |
|
| 595 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 594 | + $input_constructor_args['validation_strategies'][] = new EE_Float_Validation_Strategy(); |
|
| 595 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 596 | 596 | break; |
| 597 | 597 | case EEM_Question::QST_type_url : |
| 598 | - $input_constructor_args[ 'validation_strategies' ][] = new EE_URL_Validation_Strategy(); |
|
| 599 | - $result = new EE_Text_Input( $input_constructor_args ); |
|
| 598 | + $input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy(); |
|
| 599 | + $result = new EE_Text_Input($input_constructor_args); |
|
| 600 | 600 | break; |
| 601 | 601 | case EEM_Question::QST_type_year : |
| 602 | 602 | $result = new EE_Year_Input( |
| 603 | 603 | $input_constructor_args, |
| 604 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this ), |
|
| 605 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this ), |
|
| 606 | - apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this ) |
|
| 604 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this), |
|
| 605 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this), |
|
| 606 | + apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this) |
|
| 607 | 607 | ); |
| 608 | 608 | break; |
| 609 | 609 | case EEM_Question::QST_type_multi_select : |
| 610 | - $result = new EE_Select_Multiple_Input( $this->options(), $input_constructor_args ); |
|
| 610 | + $result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args); |
|
| 611 | 611 | break; |
| 612 | 612 | // fallback |
| 613 | 613 | default : |
@@ -618,12 +618,12 @@ discard block |
||
| 618 | 618 | $this, |
| 619 | 619 | $input_constructor_args |
| 620 | 620 | ); |
| 621 | - if( ! $default_input ){ |
|
| 622 | - $default_input = new EE_Text_Input( $input_constructor_args ); |
|
| 621 | + if ( ! $default_input) { |
|
| 622 | + $default_input = new EE_Text_Input($input_constructor_args); |
|
| 623 | 623 | } |
| 624 | 624 | $result = $default_input; |
| 625 | 625 | } |
| 626 | - return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer ); |
|
| 626 | + return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer); |
|
| 627 | 627 | } |
| 628 | 628 | |
| 629 | 629 | |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | * Adds an option for this question. Note: if the option were previously associated with a different |
| 370 | 370 | * Question, that relationship will be overwritten. |
| 371 | 371 | * @param EE_Question_Option $option |
| 372 | - * @return boolean success |
|
| 372 | + * @return EE_Base_Class success |
|
| 373 | 373 | */ |
| 374 | 374 | public function add_option( EE_Question_Option $option ) { |
| 375 | 375 | return $this->_add_relation_to( $option, 'Question_Option' ); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | /** |
| 393 | 393 | * Marks the option as deleted. |
| 394 | 394 | * @param EE_Question_Option $option |
| 395 | - * @return boolean success |
|
| 395 | + * @return EE_Base_Class success |
|
| 396 | 396 | */ |
| 397 | 397 | public function remove_option( EE_Question_Option $option ) { |
| 398 | 398 | return $this->_remove_relation_to( $option, 'Question_Option' ); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 4 | - exit( 'No direct script access allowed' ); |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 4 | + exit('No direct script access allowed'); |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | |
@@ -134,14 +134,14 @@ discard block |
||
| 134 | 134 | * @return EE_Messenger_Collection |
| 135 | 135 | */ |
| 136 | 136 | protected function _initialize_collections() { |
| 137 | - if ( $this->_initialized ) { |
|
| 137 | + if ($this->_initialized) { |
|
| 138 | 138 | return; |
| 139 | 139 | } |
| 140 | 140 | $this->_initialized = true; |
| 141 | 141 | $this->_messenger_collection_loader->load_messengers_from_folder(); |
| 142 | 142 | $this->_message_type_collection_loader->load_message_types_from_folder(); |
| 143 | 143 | $this->_set_active_messengers_and_message_types(); |
| 144 | - $this->get_has_activated_messengers_option( true ); |
|
| 144 | + $this->get_has_activated_messengers_option(true); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | * @param string $messenger_name |
| 171 | 171 | * @return \EE_messenger |
| 172 | 172 | */ |
| 173 | - public function get_messenger( $messenger_name ) { |
|
| 174 | - return $this->messenger_collection()->get_by_info( $messenger_name ); |
|
| 173 | + public function get_messenger($messenger_name) { |
|
| 174 | + return $this->messenger_collection()->get_by_info($messenger_name); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | |
@@ -182,9 +182,9 @@ discard block |
||
| 182 | 182 | * @param string $messenger |
| 183 | 183 | * @return EE_messenger | null |
| 184 | 184 | */ |
| 185 | - public function get_active_messenger( $messenger ) { |
|
| 185 | + public function get_active_messenger($messenger) { |
|
| 186 | 186 | $this->_initialize_collections(); |
| 187 | - return ! empty( $this->_active_messengers[ $messenger ] ) ? $this->_active_messengers[ $messenger ] : null; |
|
| 187 | + return ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : null; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | * @return \EE_messenger[] |
| 194 | 194 | */ |
| 195 | 195 | public function installed_messengers() { |
| 196 | - if ( empty( $this->_installed_messengers ) ) { |
|
| 196 | + if (empty($this->_installed_messengers)) { |
|
| 197 | 197 | $this->_installed_messengers = array(); |
| 198 | 198 | $this->messenger_collection()->rewind(); |
| 199 | - while ( $this->messenger_collection()->valid() ) { |
|
| 200 | - $this->_installed_messengers[ $this->messenger_collection()->current()->name ] = $this->messenger_collection()->current(); |
|
| 199 | + while ($this->messenger_collection()->valid()) { |
|
| 200 | + $this->_installed_messengers[$this->messenger_collection()->current()->name] = $this->messenger_collection()->current(); |
|
| 201 | 201 | $this->messenger_collection()->next(); |
| 202 | 202 | } |
| 203 | 203 | } |
@@ -211,14 +211,14 @@ discard block |
||
| 211 | 211 | * @return \EE_messenger |
| 212 | 212 | * @throws \EE_Error |
| 213 | 213 | */ |
| 214 | - public function valid_messenger( $messenger_name ) { |
|
| 215 | - $messenger = $this->get_messenger( $messenger_name ); |
|
| 216 | - if ( $messenger instanceof EE_messenger ) { |
|
| 214 | + public function valid_messenger($messenger_name) { |
|
| 215 | + $messenger = $this->get_messenger($messenger_name); |
|
| 216 | + if ($messenger instanceof EE_messenger) { |
|
| 217 | 217 | return $messenger; |
| 218 | 218 | } |
| 219 | 219 | throw new EE_Error( |
| 220 | 220 | sprintf( |
| 221 | - __( 'The "%1$s" messenger is either invalid or not installed', 'event_espresso' ), |
|
| 221 | + __('The "%1$s" messenger is either invalid or not installed', 'event_espresso'), |
|
| 222 | 222 | $messenger_name |
| 223 | 223 | ) |
| 224 | 224 | ); |
@@ -250,8 +250,8 @@ discard block |
||
| 250 | 250 | * @param string $message_type_name |
| 251 | 251 | * @return \EE_message_type |
| 252 | 252 | */ |
| 253 | - public function get_message_type( $message_type_name ) { |
|
| 254 | - return $this->message_type_collection()->get_by_info( $message_type_name ); |
|
| 253 | + public function get_message_type($message_type_name) { |
|
| 254 | + return $this->message_type_collection()->get_by_info($message_type_name); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
@@ -263,9 +263,9 @@ discard block |
||
| 263 | 263 | * @param string $message_type_name |
| 264 | 264 | * @return \EE_message_type|null |
| 265 | 265 | */ |
| 266 | - public function get_active_message_type_for_messenger( $messenger_name, $message_type_name ) { |
|
| 267 | - return $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) |
|
| 268 | - ? $this->get_message_type( $message_type_name ) |
|
| 266 | + public function get_active_message_type_for_messenger($messenger_name, $message_type_name) { |
|
| 267 | + return $this->is_message_type_active_for_messenger($messenger_name, $message_type_name) |
|
| 268 | + ? $this->get_message_type($message_type_name) |
|
| 269 | 269 | : null; |
| 270 | 270 | } |
| 271 | 271 | |
@@ -279,9 +279,9 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @return bool |
| 281 | 281 | */ |
| 282 | - public function is_message_type_active_for_messenger( $messenger_name, $message_type_name ) { |
|
| 282 | + public function is_message_type_active_for_messenger($messenger_name, $message_type_name) { |
|
| 283 | 283 | $this->_initialize_collections(); |
| 284 | - return ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
| 284 | + return ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | |
@@ -292,9 +292,9 @@ discard block |
||
| 292 | 292 | * @param string $messenger_name the name of the messenger to check if active. |
| 293 | 293 | * @return bool |
| 294 | 294 | */ |
| 295 | - public function is_messenger_active( $messenger_name ) { |
|
| 295 | + public function is_messenger_active($messenger_name) { |
|
| 296 | 296 | $this->_initialize_collections(); |
| 297 | - return ! empty( $this->_active_message_types[ $messenger_name ] ); |
|
| 297 | + return ! empty($this->_active_message_types[$messenger_name]); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | |
@@ -305,11 +305,11 @@ discard block |
||
| 305 | 305 | * @param string $message_type_name The slug of the message type getting the settings for. |
| 306 | 306 | * @return array |
| 307 | 307 | */ |
| 308 | - public function get_message_type_settings_for_messenger( $messenger_name, $message_type_name ) { |
|
| 308 | + public function get_message_type_settings_for_messenger($messenger_name, $message_type_name) { |
|
| 309 | 309 | $settings = array(); |
| 310 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
| 311 | - $settings = isset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] ) |
|
| 312 | - ? $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] |
|
| 310 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
| 311 | + $settings = isset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings']) |
|
| 312 | + ? $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] |
|
| 313 | 313 | : array(); |
| 314 | 314 | } |
| 315 | 315 | return $settings; |
@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | * @param string $messenger_name |
| 325 | 325 | * @return bool |
| 326 | 326 | */ |
| 327 | - public function messenger_has_active_message_types( $messenger_name ) { |
|
| 327 | + public function messenger_has_active_message_types($messenger_name) { |
|
| 328 | 328 | $this->_initialize_collections(); |
| 329 | 329 | return |
| 330 | - ! empty( $this->_active_message_types[ $messenger_name ] ) |
|
| 331 | - && ! empty( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ] ); |
|
| 330 | + ! empty($this->_active_message_types[$messenger_name]) |
|
| 331 | + && ! empty($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types']); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
@@ -341,15 +341,15 @@ discard block |
||
| 341 | 341 | * @param string $messenger_name The messenger being checked |
| 342 | 342 | * @return EE_message_type[] (or empty array if none present) |
| 343 | 343 | */ |
| 344 | - public function get_active_message_types_for_messenger( $messenger_name ) { |
|
| 344 | + public function get_active_message_types_for_messenger($messenger_name) { |
|
| 345 | 345 | $message_types = array(); |
| 346 | - if ( ! $this->messenger_has_active_message_types( $messenger_name ) ) { |
|
| 346 | + if ( ! $this->messenger_has_active_message_types($messenger_name)) { |
|
| 347 | 347 | return $message_types; |
| 348 | 348 | } |
| 349 | 349 | $installed_message_types = $this->installed_message_types(); |
| 350 | - foreach ( $installed_message_types as $message_type_name => $message_type ) { |
|
| 351 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
| 352 | - $message_types[ $message_type_name ] = $message_type; |
|
| 350 | + foreach ($installed_message_types as $message_type_name => $message_type) { |
|
| 351 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
| 352 | + $message_types[$message_type_name] = $message_type; |
|
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | return $message_types; |
@@ -367,12 +367,12 @@ discard block |
||
| 367 | 367 | public function list_of_active_message_types() { |
| 368 | 368 | $active_message_type_names = array(); |
| 369 | 369 | $this->_initialize_collections(); |
| 370 | - foreach ( $this->_active_message_types as $messenger => $messenger_settings ) { |
|
| 371 | - if ( ! isset( $messenger_settings['settings'][ $messenger . '-message_types' ] ) ) { |
|
| 370 | + foreach ($this->_active_message_types as $messenger => $messenger_settings) { |
|
| 371 | + if ( ! isset($messenger_settings['settings'][$messenger.'-message_types'])) { |
|
| 372 | 372 | continue; |
| 373 | 373 | } |
| 374 | - foreach ( $messenger_settings['settings'][ $messenger . '-message_types' ] as $message_type_name => $message_type_config ) { |
|
| 375 | - if ( ! in_array( $message_type_name, $active_message_type_names ) ) { |
|
| 374 | + foreach ($messenger_settings['settings'][$messenger.'-message_types'] as $message_type_name => $message_type_config) { |
|
| 375 | + if ( ! in_array($message_type_name, $active_message_type_names)) { |
|
| 376 | 376 | $active_message_type_names[] = $message_type_name; |
| 377 | 377 | } |
| 378 | 378 | } |
@@ -392,9 +392,9 @@ discard block |
||
| 392 | 392 | $active_message_types = array(); |
| 393 | 393 | $installed_message_types = $this->installed_message_types(); |
| 394 | 394 | $active_message_type_names = $this->list_of_active_message_types(); |
| 395 | - foreach ( $active_message_type_names as $active_message_type_name ) { |
|
| 396 | - if ( isset( $installed_message_types[ $active_message_type_name ] ) ) { |
|
| 397 | - $active_message_types[ $active_message_type_name ] = $installed_message_types[ $active_message_type_name ]; |
|
| 395 | + foreach ($active_message_type_names as $active_message_type_name) { |
|
| 396 | + if (isset($installed_message_types[$active_message_type_name])) { |
|
| 397 | + $active_message_types[$active_message_type_name] = $installed_message_types[$active_message_type_name]; |
|
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | 400 | return $active_message_types; |
@@ -406,10 +406,10 @@ discard block |
||
| 406 | 406 | * @return \EE_message_type[] |
| 407 | 407 | */ |
| 408 | 408 | public function installed_message_types() { |
| 409 | - if ( empty( $this->_installed_message_types ) ) { |
|
| 409 | + if (empty($this->_installed_message_types)) { |
|
| 410 | 410 | $this->message_type_collection()->rewind(); |
| 411 | - while ( $this->message_type_collection()->valid() ) { |
|
| 412 | - $this->_installed_message_types[ $this->message_type_collection()->current()->name ] = $this->message_type_collection()->current(); |
|
| 411 | + while ($this->message_type_collection()->valid()) { |
|
| 412 | + $this->_installed_message_types[$this->message_type_collection()->current()->name] = $this->message_type_collection()->current(); |
|
| 413 | 413 | $this->message_type_collection()->next(); |
| 414 | 414 | } |
| 415 | 415 | } |
@@ -422,14 +422,14 @@ discard block |
||
| 422 | 422 | * @return \EE_message_type |
| 423 | 423 | * @throws \EE_Error |
| 424 | 424 | */ |
| 425 | - public function valid_message_type( $message_type_name ) { |
|
| 426 | - $message_type = $this->get_message_type( $message_type_name ); |
|
| 427 | - if ( $message_type instanceof EE_message_type ) { |
|
| 425 | + public function valid_message_type($message_type_name) { |
|
| 426 | + $message_type = $this->get_message_type($message_type_name); |
|
| 427 | + if ($message_type instanceof EE_message_type) { |
|
| 428 | 428 | return $message_type; |
| 429 | 429 | } |
| 430 | 430 | throw new EE_Error( |
| 431 | 431 | sprintf( |
| 432 | - __( 'The "%1$s" message type is either invalid or not installed', 'event_espresso' ), |
|
| 432 | + __('The "%1$s" message type is either invalid or not installed', 'event_espresso'), |
|
| 433 | 433 | $message_type_name |
| 434 | 434 | ) |
| 435 | 435 | ); |
@@ -445,9 +445,9 @@ discard block |
||
| 445 | 445 | * @return boolean |
| 446 | 446 | * @throws \EE_Error |
| 447 | 447 | */ |
| 448 | - public function valid_message_type_for_messenger( EE_messenger $messenger, $message_type_name ) { |
|
| 448 | + public function valid_message_type_for_messenger(EE_messenger $messenger, $message_type_name) { |
|
| 449 | 449 | $valid_message_types = $messenger->get_valid_message_types(); |
| 450 | - if ( ! in_array( $message_type_name, $valid_message_types ) ) { |
|
| 450 | + if ( ! in_array($message_type_name, $valid_message_types)) { |
|
| 451 | 451 | throw new EE_Error( |
| 452 | 452 | sprintf( |
| 453 | 453 | __( |
@@ -474,9 +474,9 @@ discard block |
||
| 474 | 474 | * |
| 475 | 475 | * @return array |
| 476 | 476 | */ |
| 477 | - public function get_active_messengers_option( $reset = false) { |
|
| 478 | - if ( $reset ) { |
|
| 479 | - $this->_active_message_types = get_option( 'ee_active_messengers', array() ); |
|
| 477 | + public function get_active_messengers_option($reset = false) { |
|
| 478 | + if ($reset) { |
|
| 479 | + $this->_active_message_types = get_option('ee_active_messengers', array()); |
|
| 480 | 480 | } |
| 481 | 481 | return $this->_active_message_types; |
| 482 | 482 | } |
@@ -490,11 +490,11 @@ discard block |
||
| 490 | 490 | * representing this data is used. |
| 491 | 491 | * @return bool FALSE if not updated, TRUE if updated. |
| 492 | 492 | */ |
| 493 | - public function update_active_messengers_option( $active_messenger_settings = array() ) { |
|
| 494 | - $active_messenger_settings = empty( $active_messenger_settings ) ? $this->_active_message_types : $active_messenger_settings; |
|
| 493 | + public function update_active_messengers_option($active_messenger_settings = array()) { |
|
| 494 | + $active_messenger_settings = empty($active_messenger_settings) ? $this->_active_message_types : $active_messenger_settings; |
|
| 495 | 495 | //make sure _active_message_types is updated (this is the internal cache for the settings). |
| 496 | 496 | $this->_active_message_types = $active_messenger_settings; |
| 497 | - return update_option( 'ee_active_messengers', $active_messenger_settings ); |
|
| 497 | + return update_option('ee_active_messengers', $active_messenger_settings); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | |
@@ -509,9 +509,9 @@ discard block |
||
| 509 | 509 | * |
| 510 | 510 | * @return array |
| 511 | 511 | */ |
| 512 | - public function get_has_activated_messengers_option( $reset = false ) { |
|
| 513 | - if ( $reset ) { |
|
| 514 | - $this->_has_activated_messengers_and_message_types = get_option( 'ee_has_activated_messenger', array() ); |
|
| 512 | + public function get_has_activated_messengers_option($reset = false) { |
|
| 513 | + if ($reset) { |
|
| 514 | + $this->_has_activated_messengers_and_message_types = get_option('ee_has_activated_messenger', array()); |
|
| 515 | 515 | } |
| 516 | 516 | return $this->_has_activated_messengers_and_message_types; |
| 517 | 517 | } |
@@ -526,11 +526,11 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return bool FALSE if not updated, TRUE if updated. |
| 528 | 528 | */ |
| 529 | - public function update_has_activated_messengers_option( $has_activated_messengers = array() ) { |
|
| 530 | - $has_activated_messengers = empty( $has_activated_messengers ) |
|
| 529 | + public function update_has_activated_messengers_option($has_activated_messengers = array()) { |
|
| 530 | + $has_activated_messengers = empty($has_activated_messengers) |
|
| 531 | 531 | ? $this->_has_activated_messengers_and_message_types |
| 532 | 532 | : $has_activated_messengers; |
| 533 | - return update_option( 'ee_has_activated_messenger', $has_activated_messengers ); |
|
| 533 | + return update_option('ee_has_activated_messenger', $has_activated_messengers); |
|
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | |
@@ -552,8 +552,8 @@ discard block |
||
| 552 | 552 | //echo "\n\n " . __LINE__ . ") " . __METHOD__ . "() \n"; |
| 553 | 553 | // list of activated messengers as set via the admin |
| 554 | 554 | // note calling `get_active_messengers_options` also initializes the _active_message_types property. |
| 555 | - $this->get_active_messengers_option( true ); |
|
| 556 | - $this->ensure_messengers_are_active( array(), false, true ); |
|
| 555 | + $this->get_active_messengers_option(true); |
|
| 556 | + $this->ensure_messengers_are_active(array(), false, true); |
|
| 557 | 557 | $this->update_active_messengers_option(); |
| 558 | 558 | $this->update_has_activated_messengers_option(); |
| 559 | 559 | } |
@@ -571,11 +571,11 @@ discard block |
||
| 571 | 571 | * @param bool $update_option Whether to update the option in the db or not. |
| 572 | 572 | * @return boolean true if either already active or successfully activated. |
| 573 | 573 | */ |
| 574 | - public function ensure_messenger_is_active( $messenger_name, $update_option = true ) { |
|
| 575 | - if ( ! isset( $this->_active_messengers[ $messenger_name ] ) ) { |
|
| 574 | + public function ensure_messenger_is_active($messenger_name, $update_option = true) { |
|
| 575 | + if ( ! isset($this->_active_messengers[$messenger_name])) { |
|
| 576 | 576 | try { |
| 577 | - $this->activate_messenger( $messenger_name, array(), $update_option ); |
|
| 578 | - } catch( EE_Error $e ) { |
|
| 577 | + $this->activate_messenger($messenger_name, array(), $update_option); |
|
| 578 | + } catch (EE_Error $e) { |
|
| 579 | 579 | EE_Error::add_error( |
| 580 | 580 | $e->getMessage(), |
| 581 | 581 | __FILE__, |
@@ -602,25 +602,25 @@ discard block |
||
| 602 | 602 | * and a messenger is indicated as active, but is NOT installed, then it will automatically be |
| 603 | 603 | * deactivated. |
| 604 | 604 | */ |
| 605 | - public function ensure_messengers_are_active( $messenger_names = array(), $update_option = true, $verify = false ) { |
|
| 606 | - $messenger_names = empty( $messenger_names ) ? array_keys( $this->_active_message_types ) : $messenger_names; |
|
| 605 | + public function ensure_messengers_are_active($messenger_names = array(), $update_option = true, $verify = false) { |
|
| 606 | + $messenger_names = empty($messenger_names) ? array_keys($this->_active_message_types) : $messenger_names; |
|
| 607 | 607 | |
| 608 | 608 | $not_installed = array(); |
| 609 | - foreach( $messenger_names as $messenger_name ) { |
|
| 610 | - if ( $verify && ! $this->messenger_collection()->has_by_name( $messenger_name ) ) { |
|
| 609 | + foreach ($messenger_names as $messenger_name) { |
|
| 610 | + if ($verify && ! $this->messenger_collection()->has_by_name($messenger_name)) { |
|
| 611 | 611 | $not_installed[] = $messenger_name; |
| 612 | - $this->deactivate_messenger( $messenger_name ); |
|
| 612 | + $this->deactivate_messenger($messenger_name); |
|
| 613 | 613 | continue; |
| 614 | 614 | } |
| 615 | - $this->ensure_messenger_is_active( $messenger_name, $update_option ); |
|
| 615 | + $this->ensure_messenger_is_active($messenger_name, $update_option); |
|
| 616 | 616 | } |
| 617 | 617 | |
| 618 | - if ( ! empty( $not_installed_messenger ) ) { |
|
| 618 | + if ( ! empty($not_installed_messenger)) { |
|
| 619 | 619 | EE_Error::add_error( |
| 620 | 620 | sprintf( |
| 621 | - __( 'The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso' ), |
|
| 621 | + __('The following messengers are either not installed or are invalid:%1$s %2$s', 'event_espresso'), |
|
| 622 | 622 | '<br />', |
| 623 | - implode( ', ', $not_installed_messenger ) |
|
| 623 | + implode(', ', $not_installed_messenger) |
|
| 624 | 624 | ), |
| 625 | 625 | __FILE__, __FUNCTION__, __LINE__ |
| 626 | 626 | ); |
@@ -639,18 +639,18 @@ discard block |
||
| 639 | 639 | * @return bool Returns true if already is active or if was activated successfully. |
| 640 | 640 | * @throws \EE_Error |
| 641 | 641 | */ |
| 642 | - public function ensure_message_type_is_active( $message_type_name, $messenger_name, $update_option = true ) { |
|
| 642 | + public function ensure_message_type_is_active($message_type_name, $messenger_name, $update_option = true) { |
|
| 643 | 643 | // grab the messenger to work with. |
| 644 | - $messenger = $this->valid_messenger( $messenger_name ); |
|
| 645 | - if ( $this->valid_message_type_for_messenger( $messenger, $message_type_name ) ) { |
|
| 644 | + $messenger = $this->valid_messenger($messenger_name); |
|
| 645 | + if ($this->valid_message_type_for_messenger($messenger, $message_type_name)) { |
|
| 646 | 646 | //ensure messenger is active (that's an inherent coupling between active message types and the |
| 647 | 647 | //messenger they are being activated for. |
| 648 | 648 | try { |
| 649 | - if ( ! $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
| 649 | + if ( ! $this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
| 650 | 650 | //all is good so let's just get it active |
| 651 | - $this->activate_messenger( $messenger_name, array( $message_type_name ), $update_option ); |
|
| 651 | + $this->activate_messenger($messenger_name, array($message_type_name), $update_option); |
|
| 652 | 652 | } |
| 653 | - } catch( EE_Error $e ) { |
|
| 653 | + } catch (EE_Error $e) { |
|
| 654 | 654 | EE_Error::add_error( |
| 655 | 655 | $e->getMessage(), |
| 656 | 656 | __FILE__, |
@@ -674,14 +674,14 @@ discard block |
||
| 674 | 674 | * @param string $messenger_name The name of the messenger that the message types are to be activated on. |
| 675 | 675 | * @param bool $update_option Whether to persist the activation to the database or not (default true). |
| 676 | 676 | */ |
| 677 | - public function ensure_message_types_are_active( $message_type_names, $messenger_name, $update_option = true ) { |
|
| 677 | + public function ensure_message_types_are_active($message_type_names, $messenger_name, $update_option = true) { |
|
| 678 | 678 | $message_type_names = (array) $message_type_names; |
| 679 | - foreach ( $message_type_names as $message_type_name ) { |
|
| 679 | + foreach ($message_type_names as $message_type_name) { |
|
| 680 | 680 | // note, intentionally not updating option here because we're in a loop. |
| 681 | 681 | // We'll follow the instructions of the incoming $update_option argument after the loop. |
| 682 | - $this->ensure_message_type_is_active( $message_type_name, $messenger_name, false ); |
|
| 682 | + $this->ensure_message_type_is_active($message_type_name, $messenger_name, false); |
|
| 683 | 683 | } |
| 684 | - if ( $update_option ) { |
|
| 684 | + if ($update_option) { |
|
| 685 | 685 | $this->update_active_messengers_option(); |
| 686 | 686 | $this->update_has_activated_messengers_option(); |
| 687 | 687 | } |
@@ -708,24 +708,24 @@ discard block |
||
| 708 | 708 | ) { |
| 709 | 709 | $templates = array(); |
| 710 | 710 | // grab the messenger to work with. |
| 711 | - $messenger = $this->messenger_collection()->get_by_info( $messenger_name ); |
|
| 711 | + $messenger = $this->messenger_collection()->get_by_info($messenger_name); |
|
| 712 | 712 | // it's inactive. Activate it. |
| 713 | - if ( $messenger instanceof EE_messenger ) { |
|
| 714 | - $this->_active_messengers[ $messenger->name ] = $messenger; |
|
| 713 | + if ($messenger instanceof EE_messenger) { |
|
| 714 | + $this->_active_messengers[$messenger->name] = $messenger; |
|
| 715 | 715 | //activate incoming message types set to be activated with messenger. |
| 716 | - $message_type_names = $this->_activate_message_types( $messenger, $message_type_names ); |
|
| 716 | + $message_type_names = $this->_activate_message_types($messenger, $message_type_names); |
|
| 717 | 717 | // setup any initial settings for the messenger if necessary. |
| 718 | - $this->add_settings_for_messenger( $messenger->name ); |
|
| 719 | - if ( $update_active_messengers_option ) { |
|
| 718 | + $this->add_settings_for_messenger($messenger->name); |
|
| 719 | + if ($update_active_messengers_option) { |
|
| 720 | 720 | $this->update_active_messengers_option(); |
| 721 | 721 | $this->update_has_activated_messengers_option(); |
| 722 | 722 | } |
| 723 | 723 | //generate new templates if necessary and ensure all related templates that are already in the database are |
| 724 | 724 | //marked active. Note, this will also deactivate a message type for a messenger if the template |
| 725 | 725 | //cannot be successfully created during its attempt (only happens for global template attempts). |
| 726 | - if ( ! empty( $message_type_names ) ) { |
|
| 727 | - $templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $message_type_names, 0, true ); |
|
| 728 | - EEH_MSG_Template::update_to_active( array( $messenger->name ), $message_type_names ); |
|
| 726 | + if ( ! empty($message_type_names)) { |
|
| 727 | + $templates = EEH_MSG_Template::generate_new_templates($messenger->name, $message_type_names, 0, true); |
|
| 728 | + EEH_MSG_Template::update_to_active(array($messenger->name), $message_type_names); |
|
| 729 | 729 | } |
| 730 | 730 | } |
| 731 | 731 | return $templates; |
@@ -744,29 +744,29 @@ discard block |
||
| 744 | 744 | * |
| 745 | 745 | * @return array |
| 746 | 746 | */ |
| 747 | - protected function _activate_message_types( EE_messenger $messenger, $message_type_names = array() ) { |
|
| 747 | + protected function _activate_message_types(EE_messenger $messenger, $message_type_names = array()) { |
|
| 748 | 748 | //If $message_type_names is empty, AND $this->_active_message_types is empty, then that means |
| 749 | 749 | //things have never been initialized (which should happen on EEH_Activation::generate_message_templates). |
| 750 | 750 | //So ONLY then do we need to actually grab defaults and cycle through them. Otherwise we |
| 751 | 751 | //only override _active_message_types when an explicit array of $message_type_names has been provided. |
| 752 | - $message_type_names = empty( $message_type_names ) && ! isset( $this->_active_message_types[ $messenger->name ] ) |
|
| 752 | + $message_type_names = empty($message_type_names) && ! isset($this->_active_message_types[$messenger->name]) |
|
| 753 | 753 | ? $messenger->get_default_message_types() |
| 754 | 754 | : (array) $message_type_names; |
| 755 | 755 | |
| 756 | 756 | //now we ALWAYS need to make sure that the messenger is active for the message types we're activating! |
| 757 | - if ( ! isset( $this->_active_message_types[ $messenger->name ] ) ) { |
|
| 758 | - $this->_active_message_types[ $messenger->name ]['settings'] = array(); |
|
| 757 | + if ( ! isset($this->_active_message_types[$messenger->name])) { |
|
| 758 | + $this->_active_message_types[$messenger->name]['settings'] = array(); |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if ( $message_type_names ) { |
|
| 761 | + if ($message_type_names) { |
|
| 762 | 762 | // cycle thru message types |
| 763 | - foreach ( $message_type_names as $message_type_name ) { |
|
| 763 | + foreach ($message_type_names as $message_type_name) { |
|
| 764 | 764 | //only register the message type as active IF it isn't already active! |
| 765 | 765 | //and if its actually installed. |
| 766 | 766 | if ( |
| 767 | - ! $this->is_message_type_active_for_messenger( $messenger->name, $message_type_name ) |
|
| 767 | + ! $this->is_message_type_active_for_messenger($messenger->name, $message_type_name) |
|
| 768 | 768 | ) { |
| 769 | - $this->add_settings_for_message_type( $messenger->name, $message_type_name ); |
|
| 769 | + $this->add_settings_for_message_type($messenger->name, $message_type_name); |
|
| 770 | 770 | $this->_set_messenger_has_activated_message_type( |
| 771 | 771 | $messenger, |
| 772 | 772 | $message_type_name |
@@ -789,24 +789,24 @@ discard block |
||
| 789 | 789 | * @param string $message_type_name The name of the message type adding the settings for |
| 790 | 790 | * @param array $new_settings Any new settings being set for the message type and messenger |
| 791 | 791 | */ |
| 792 | - public function add_settings_for_message_type( $messenger_name, $message_type_name, $new_settings = array() ) { |
|
| 792 | + public function add_settings_for_message_type($messenger_name, $message_type_name, $new_settings = array()) { |
|
| 793 | 793 | // get installed message type from collection |
| 794 | - $message_type = $this->message_type_collection()->get_by_info( $message_type_name ); |
|
| 795 | - $existing_settings = $this->get_message_type_settings_for_messenger( $messenger_name, $message_type_name ); |
|
| 794 | + $message_type = $this->message_type_collection()->get_by_info($message_type_name); |
|
| 795 | + $existing_settings = $this->get_message_type_settings_for_messenger($messenger_name, $message_type_name); |
|
| 796 | 796 | //we need to setup any initial settings for message types |
| 797 | - if ( $message_type instanceof EE_message_type ) { |
|
| 797 | + if ($message_type instanceof EE_message_type) { |
|
| 798 | 798 | $default_settings = $message_type->get_admin_settings_fields(); |
| 799 | - foreach ( $default_settings as $field => $values ) { |
|
| 800 | - if ( isset( $new_settings[ $field ] ) ) { |
|
| 801 | - $existing_settings[ $field ] = $new_settings[ $field ]; |
|
| 799 | + foreach ($default_settings as $field => $values) { |
|
| 800 | + if (isset($new_settings[$field])) { |
|
| 801 | + $existing_settings[$field] = $new_settings[$field]; |
|
| 802 | 802 | continue; |
| 803 | 803 | } |
| 804 | - if ( ! isset( $existing_settings[ $field ] ) ) { |
|
| 805 | - $existing_settings[ $field ] = $values['default']; |
|
| 804 | + if ( ! isset($existing_settings[$field])) { |
|
| 805 | + $existing_settings[$field] = $values['default']; |
|
| 806 | 806 | } |
| 807 | 807 | } |
| 808 | 808 | } |
| 809 | - $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ]['settings'] = $existing_settings; |
|
| 809 | + $this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]['settings'] = $existing_settings; |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | |
@@ -819,14 +819,14 @@ discard block |
||
| 819 | 819 | * @param \EE_messenger $messenger |
| 820 | 820 | * @param string $message_type_name |
| 821 | 821 | */ |
| 822 | - protected function _set_messenger_has_activated_message_type( EE_messenger $messenger, $message_type_name ) { |
|
| 822 | + protected function _set_messenger_has_activated_message_type(EE_messenger $messenger, $message_type_name) { |
|
| 823 | 823 | // make sure this messenger has a record in the has_activated array |
| 824 | - if ( ! isset( $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
| 825 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ] = array(); |
|
| 824 | + if ( ! isset($this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
| 825 | + $this->_has_activated_messengers_and_message_types[$messenger->name] = array(); |
|
| 826 | 826 | } |
| 827 | 827 | // check if message type has already been added |
| 828 | - if ( ! in_array( $message_type_name, $this->_has_activated_messengers_and_message_types[ $messenger->name ] ) ) { |
|
| 829 | - $this->_has_activated_messengers_and_message_types[ $messenger->name ][] = $message_type_name; |
|
| 828 | + if ( ! in_array($message_type_name, $this->_has_activated_messengers_and_message_types[$messenger->name])) { |
|
| 829 | + $this->_has_activated_messengers_and_message_types[$messenger->name][] = $message_type_name; |
|
| 830 | 830 | } |
| 831 | 831 | } |
| 832 | 832 | |
@@ -841,20 +841,20 @@ discard block |
||
| 841 | 841 | * @param string $messenger_name The name of the messenger the settings is being added for. |
| 842 | 842 | * @param array $new_settings An array of settings to update the existing settings. |
| 843 | 843 | */ |
| 844 | - public function add_settings_for_messenger( $messenger_name, $new_settings = array() ) { |
|
| 845 | - $messenger = $this->get_messenger( $messenger_name ); |
|
| 846 | - if ( $messenger instanceof EE_messenger ) { |
|
| 844 | + public function add_settings_for_messenger($messenger_name, $new_settings = array()) { |
|
| 845 | + $messenger = $this->get_messenger($messenger_name); |
|
| 846 | + if ($messenger instanceof EE_messenger) { |
|
| 847 | 847 | $msgr_settings = $messenger->get_admin_settings_fields(); |
| 848 | - if ( ! empty( $msgr_settings ) ) { |
|
| 849 | - foreach ( $msgr_settings as $field => $value ) { |
|
| 848 | + if ( ! empty($msgr_settings)) { |
|
| 849 | + foreach ($msgr_settings as $field => $value) { |
|
| 850 | 850 | //is there a new setting for this? |
| 851 | - if ( isset( $new_settings[ $field ] ) ) { |
|
| 852 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $new_settings[ $field ]; |
|
| 851 | + if (isset($new_settings[$field])) { |
|
| 852 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $new_settings[$field]; |
|
| 853 | 853 | continue; |
| 854 | 854 | } |
| 855 | 855 | //only set the default if it isn't already set. |
| 856 | - if ( ! isset( $this->_active_message_types[ $messenger->name ]['settings'][ $field ] ) ) { |
|
| 857 | - $this->_active_message_types[ $messenger->name ]['settings'][ $field ] = $value; |
|
| 856 | + if ( ! isset($this->_active_message_types[$messenger->name]['settings'][$field])) { |
|
| 857 | + $this->_active_message_types[$messenger->name]['settings'][$field] = $value; |
|
| 858 | 858 | } |
| 859 | 859 | } |
| 860 | 860 | } |
@@ -869,13 +869,13 @@ discard block |
||
| 869 | 869 | * @param string|EE_messenger $messenger_name name of messenger |
| 870 | 870 | * @return void |
| 871 | 871 | */ |
| 872 | - public function deactivate_messenger( $messenger_name ) { |
|
| 873 | - if ( $messenger_name instanceof EE_messenger ) { |
|
| 872 | + public function deactivate_messenger($messenger_name) { |
|
| 873 | + if ($messenger_name instanceof EE_messenger) { |
|
| 874 | 874 | $messenger_name = $messenger_name->name; |
| 875 | 875 | } |
| 876 | - unset( $this->_active_messengers[ $messenger_name ] ); |
|
| 877 | - unset( $this->_active_message_types[ $messenger_name ] ); |
|
| 878 | - $this->_message_template_group_model->deactivate_message_template_groups_for( $messenger_name ); |
|
| 876 | + unset($this->_active_messengers[$messenger_name]); |
|
| 877 | + unset($this->_active_message_types[$messenger_name]); |
|
| 878 | + $this->_message_template_group_model->deactivate_message_template_groups_for($messenger_name); |
|
| 879 | 879 | $this->update_active_messengers_option(); |
| 880 | 880 | } |
| 881 | 881 | |
@@ -885,16 +885,16 @@ discard block |
||
| 885 | 885 | * |
| 886 | 886 | * @param string $message_type_name name of message type being deactivated |
| 887 | 887 | */ |
| 888 | - public function deactivate_message_type( $message_type_name ) { |
|
| 889 | - if ( $message_type_name instanceof EE_message_type ) { |
|
| 888 | + public function deactivate_message_type($message_type_name) { |
|
| 889 | + if ($message_type_name instanceof EE_message_type) { |
|
| 890 | 890 | $message_type_name = $message_type_name->name; |
| 891 | 891 | } |
| 892 | - foreach ( $this->_active_message_types as $messenger => $settings ) { |
|
| 892 | + foreach ($this->_active_message_types as $messenger => $settings) { |
|
| 893 | 893 | unset( |
| 894 | - $this->_active_message_types[ $messenger ]['settings'][ $messenger . '-message_types' ][ $message_type_name ] |
|
| 894 | + $this->_active_message_types[$messenger]['settings'][$messenger.'-message_types'][$message_type_name] |
|
| 895 | 895 | ); |
| 896 | 896 | } |
| 897 | - $this->_message_template_group_model->deactivate_message_template_groups_for( '', $message_type_name ); |
|
| 897 | + $this->_message_template_group_model->deactivate_message_template_groups_for('', $message_type_name); |
|
| 898 | 898 | $this->update_active_messengers_option(); |
| 899 | 899 | } |
| 900 | 900 | |
@@ -908,11 +908,11 @@ discard block |
||
| 908 | 908 | * @param string $message_type_name Name of message type being deactivated. |
| 909 | 909 | * @param string $messenger_name Name of messenger the message type is being deactivated for. |
| 910 | 910 | */ |
| 911 | - public function deactivate_message_type_for_messenger( $message_type_name, $messenger_name ) { |
|
| 912 | - if ( $this->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) { |
|
| 913 | - unset( $this->_active_message_types[ $messenger_name ]['settings'][ $messenger_name . '-message_types' ][ $message_type_name ] ); |
|
| 911 | + public function deactivate_message_type_for_messenger($message_type_name, $messenger_name) { |
|
| 912 | + if ($this->is_message_type_active_for_messenger($messenger_name, $message_type_name)) { |
|
| 913 | + unset($this->_active_message_types[$messenger_name]['settings'][$messenger_name.'-message_types'][$message_type_name]); |
|
| 914 | 914 | } |
| 915 | - $this->_message_template_group_model->deactivate_message_template_groups_for( array( $messenger_name ), array( $message_type_name ) ); |
|
| 915 | + $this->_message_template_group_model->deactivate_message_template_groups_for(array($messenger_name), array($message_type_name)); |
|
| 916 | 916 | $this->update_active_messengers_option(); |
| 917 | 917 | } |
| 918 | 918 | |
@@ -929,12 +929,12 @@ discard block |
||
| 929 | 929 | * |
| 930 | 930 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 931 | 931 | */ |
| 932 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 932 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 933 | 933 | //get the $messengers the message type says it can be used with. |
| 934 | - foreach ( $message_type->with_messengers() as $generating_messenger => $secondary_messengers ) { |
|
| 934 | + foreach ($message_type->with_messengers() as $generating_messenger => $secondary_messengers) { |
|
| 935 | 935 | if ( |
| 936 | 936 | $messenger->name === $generating_messenger |
| 937 | - && $this->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) |
|
| 937 | + && $this->is_message_type_active_for_messenger($messenger->name, $message_type->name) |
|
| 938 | 938 | ) { |
| 939 | 939 | return true; |
| 940 | 940 | } |
@@ -971,25 +971,25 @@ discard block |
||
| 971 | 971 | * or all contexts indexed by message type. |
| 972 | 972 | * @return array |
| 973 | 973 | */ |
| 974 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 974 | + public function get_all_contexts($slugs_only = true) { |
|
| 975 | 975 | $key = $slugs_only ? 'slugs' : 'all'; |
| 976 | 976 | // check if contexts has been setup yet. |
| 977 | - if ( empty( $this->_contexts[ $key ] ) ) { |
|
| 977 | + if (empty($this->_contexts[$key])) { |
|
| 978 | 978 | // So let's get all active message type objects and loop through to get all unique contexts |
| 979 | - foreach ( $this->get_active_message_type_objects() as $message_type ) { |
|
| 980 | - if ( $message_type instanceof EE_message_type ) { |
|
| 979 | + foreach ($this->get_active_message_type_objects() as $message_type) { |
|
| 980 | + if ($message_type instanceof EE_message_type) { |
|
| 981 | 981 | $message_type_contexts = $message_type->get_contexts(); |
| 982 | - if ( $slugs_only ) { |
|
| 983 | - foreach ( $message_type_contexts as $context => $context_details ) { |
|
| 984 | - $this->_contexts[ $key ][ $context ] = $context_details[ 'label' ]; |
|
| 982 | + if ($slugs_only) { |
|
| 983 | + foreach ($message_type_contexts as $context => $context_details) { |
|
| 984 | + $this->_contexts[$key][$context] = $context_details['label']; |
|
| 985 | 985 | } |
| 986 | 986 | } else { |
| 987 | - $this->_contexts[ $key ][ $message_type->name ] = $message_type_contexts; |
|
| 987 | + $this->_contexts[$key][$message_type->name] = $message_type_contexts; |
|
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | } |
| 992 | - return ! empty( $this->_contexts[ $key ] ) ? $this->_contexts[ $key ] : array(); |
|
| 992 | + return ! empty($this->_contexts[$key]) ? $this->_contexts[$key] : array(); |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | |
@@ -1008,9 +1008,9 @@ discard block |
||
| 1008 | 1008 | $installed_message_types = $this->installed_message_types(); |
| 1009 | 1009 | $all_message_types_valid = true; |
| 1010 | 1010 | //loop through list of active message types and verify they are installed. |
| 1011 | - foreach( $list_of_active_message_type_names as $message_type_name ) { |
|
| 1012 | - if ( ! isset( $installed_message_types[$message_type_name] ) ) { |
|
| 1013 | - $this->deactivate_message_type( $message_type_name ); |
|
| 1011 | + foreach ($list_of_active_message_type_names as $message_type_name) { |
|
| 1012 | + if ( ! isset($installed_message_types[$message_type_name])) { |
|
| 1013 | + $this->deactivate_message_type($message_type_name); |
|
| 1014 | 1014 | $all_message_types_valid = false; |
| 1015 | 1015 | } |
| 1016 | 1016 | } |
@@ -1029,10 +1029,10 @@ discard block |
||
| 1029 | 1029 | * @param $messenger_name |
| 1030 | 1030 | * @return bool |
| 1031 | 1031 | */ |
| 1032 | - public function has_message_type_been_activated_for_messenger( $message_type_name, $messenger_name ) { |
|
| 1032 | + public function has_message_type_been_activated_for_messenger($message_type_name, $messenger_name) { |
|
| 1033 | 1033 | $has_activated = $this->get_has_activated_messengers_option(); |
| 1034 | - return isset( $has_activated[ $messenger_name ] ) |
|
| 1035 | - && in_array( $message_type_name, $has_activated[ $messenger_name ] ); |
|
| 1034 | + return isset($has_activated[$messenger_name]) |
|
| 1035 | + && in_array($message_type_name, $has_activated[$messenger_name]); |
|
| 1036 | 1036 | } |
| 1037 | 1037 | } |
| 1038 | 1038 | // End of file EE_Message_Resource_Manager.lib.php |
@@ -50,79 +50,79 @@ discard block |
||
| 50 | 50 | * @throws \EE_Error |
| 51 | 51 | * } |
| 52 | 52 | */ |
| 53 | - public static function register( $mt_name = NULL, $setup_args = array() ) { |
|
| 53 | + public static function register($mt_name = NULL, $setup_args = array()) { |
|
| 54 | 54 | //required fields MUST be present, so let's make sure they are. |
| 55 | 55 | if ( |
| 56 | - ! isset( $mt_name ) |
|
| 57 | - || ! is_array( $setup_args ) |
|
| 58 | - || empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] ) |
|
| 59 | - ){ |
|
| 56 | + ! isset($mt_name) |
|
| 57 | + || ! is_array($setup_args) |
|
| 58 | + || empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths']) |
|
| 59 | + ) { |
|
| 60 | 60 | throw new EE_Error( |
| 61 | - __( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' ) |
|
| 61 | + __('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso') |
|
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //make sure we don't register twice |
| 66 | - if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){ |
|
| 66 | + if (isset(self::$_ee_message_type_registry[$mt_name])) { |
|
| 67 | 67 | return; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | //make sure this was called in the right place! |
| 71 | 71 | if ( |
| 72 | - ! did_action( 'EE_Brewing_Regular___messages_caf' ) |
|
| 73 | - || did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' ) |
|
| 72 | + ! did_action('EE_Brewing_Regular___messages_caf') |
|
| 73 | + || did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations') |
|
| 74 | 74 | ) { |
| 75 | 75 | EE_Error::doing_it_wrong( |
| 76 | 76 | __METHOD__, |
| 77 | 77 | sprintf( |
| 78 | - __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'), |
|
| 78 | + __('A message type named "%s" has been attempted to be registered with the EE Messages System. It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'), |
|
| 79 | 79 | $mt_name |
| 80 | 80 | ), |
| 81 | 81 | '4.3.0' |
| 82 | 82 | ); |
| 83 | 83 | } |
| 84 | 84 | //setup $__ee_message_type_registry array from incoming values. |
| 85 | - self::$_ee_message_type_registry[ $mt_name ] = array( |
|
| 85 | + self::$_ee_message_type_registry[$mt_name] = array( |
|
| 86 | 86 | 'mtfilename' => (string) $setup_args['mtfilename'], |
| 87 | 87 | 'autoloadpaths' => (array) $setup_args['autoloadpaths'], |
| 88 | - 'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] ) |
|
| 88 | + 'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with']) |
|
| 89 | 89 | ? (array) $setup_args['messengers_to_activate_with'] |
| 90 | 90 | : array(), |
| 91 | - 'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] ) |
|
| 91 | + 'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with']) |
|
| 92 | 92 | ? (array) $setup_args['messengers_to_validate_with'] |
| 93 | 93 | : array(), |
| 94 | - 'force_activation' => ! empty( $setup_args['force_activation'] ) |
|
| 94 | + 'force_activation' => ! empty($setup_args['force_activation']) |
|
| 95 | 95 | ? (bool) $setup_args['force_activation'] |
| 96 | 96 | : array() |
| 97 | 97 | ); |
| 98 | 98 | //add filters |
| 99 | 99 | add_filter( |
| 100 | 100 | 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', |
| 101 | - array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths' ), |
|
| 101 | + array('EE_Register_Message_Type', 'register_msgs_autoload_paths'), |
|
| 102 | 102 | 10 |
| 103 | 103 | ); |
| 104 | 104 | add_filter( |
| 105 | 105 | 'FHEE__EE_messages__get_installed__messagetype_files', |
| 106 | - array( 'EE_Register_Message_Type', 'register_messagetype_files' ), |
|
| 106 | + array('EE_Register_Message_Type', 'register_messagetype_files'), |
|
| 107 | 107 | 10, |
| 108 | 108 | 1 |
| 109 | 109 | ); |
| 110 | 110 | add_filter( |
| 111 | 111 | 'FHEE__EE_messenger__get_default_message_types__default_types', |
| 112 | - array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with' ), |
|
| 112 | + array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'), |
|
| 113 | 113 | 10, |
| 114 | 114 | 2 |
| 115 | 115 | ); |
| 116 | 116 | add_filter( |
| 117 | 117 | 'FHEE__EE_messenger__get_valid_message_types__valid_types', |
| 118 | - array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with' ), |
|
| 118 | + array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'), |
|
| 119 | 119 | 10, |
| 120 | 120 | 2 |
| 121 | 121 | ); |
| 122 | 122 | //actions |
| 123 | 123 | add_action( |
| 124 | 124 | 'AHEE__EE_Addon__initialize_default_data__begin', |
| 125 | - array( 'EE_Register_Message_Type', 'set_defaults' ) |
|
| 125 | + array('EE_Register_Message_Type', 'set_defaults') |
|
| 126 | 126 | ); |
| 127 | 127 | } |
| 128 | 128 | |
@@ -133,15 +133,15 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | public static function set_defaults() { |
| 135 | 135 | /** @type EE_Message_Resource_Manager $message_resource_manager */ |
| 136 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 136 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 137 | 137 | |
| 138 | 138 | //for any message types with force activation, let's ensure they are activated |
| 139 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $settings ) { |
|
| 140 | - if ( $settings['force_activation'] ) { |
|
| 141 | - foreach ( $settings['messengers_to_activate_with'] as $messenger ) { |
|
| 139 | + foreach (self::$_ee_message_type_registry as $message_type_name => $settings) { |
|
| 140 | + if ($settings['force_activation']) { |
|
| 141 | + foreach ($settings['messengers_to_activate_with'] as $messenger) { |
|
| 142 | 142 | //DO not force activation if this message type has already been activated in the system |
| 143 | - if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger( $message_type_name, $messenger ) ) { |
|
| 144 | - $message_resource_manager->ensure_message_type_is_active( $message_type_name, $messenger ); |
|
| 143 | + if ( ! $message_resource_manager->has_message_type_been_activated_for_messenger($message_type_name, $messenger)) { |
|
| 144 | + $message_resource_manager->ensure_message_type_is_active($message_type_name, $messenger); |
|
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | * @param string $message_type_name the name for the message type that was previously registered |
| 159 | 159 | * @return void |
| 160 | 160 | */ |
| 161 | - public static function deregister( $message_type_name = null ) { |
|
| 162 | - if ( ! empty( self::$_ee_message_type_registry[ $message_type_name ] ) ) { |
|
| 161 | + public static function deregister($message_type_name = null) { |
|
| 162 | + if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) { |
|
| 163 | 163 | //let's make sure that we remove any place this message type was made active |
| 164 | 164 | /** @var EE_Message_Resource_Manager $Message_Resource_Manager */ |
| 165 | - $Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 166 | - $Message_Resource_Manager->deactivate_message_type( $message_type_name ); |
|
| 167 | - unset( self::$_ee_message_type_registry[ $message_type_name ] ); |
|
| 165 | + $Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 166 | + $Message_Resource_Manager->deactivate_message_type($message_type_name); |
|
| 167 | + unset(self::$_ee_message_type_registry[$message_type_name]); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | * @param array $messagetype_files The current array of message type file names |
| 179 | 179 | * @return array Array of message type file names |
| 180 | 180 | */ |
| 181 | - public static function register_messagetype_files( $messagetype_files ) { |
|
| 182 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
| 181 | + public static function register_messagetype_files($messagetype_files) { |
|
| 182 | + if (empty(self::$_ee_message_type_registry)) { |
|
| 183 | 183 | return $messagetype_files; |
| 184 | 184 | } |
| 185 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
| 186 | - if ( empty( $mt_reg['mtfilename' ] ) ) { |
|
| 185 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
| 186 | + if (empty($mt_reg['mtfilename'])) { |
|
| 187 | 187 | continue; |
| 188 | 188 | } |
| 189 | 189 | $messagetype_files[] = $mt_reg['mtfilename']; |
@@ -203,13 +203,13 @@ discard block |
||
| 203 | 203 | * @param array $paths array of paths to be checked by EE_messages autoloader. |
| 204 | 204 | * @return array |
| 205 | 205 | */ |
| 206 | - public static function register_msgs_autoload_paths( $paths ) { |
|
| 207 | - if ( ! empty( self::$_ee_message_type_registry ) ) { |
|
| 208 | - foreach ( self::$_ee_message_type_registry as $mt_reg ) { |
|
| 209 | - if ( empty( $mt_reg['autoloadpaths'] ) ) { |
|
| 206 | + public static function register_msgs_autoload_paths($paths) { |
|
| 207 | + if ( ! empty(self::$_ee_message_type_registry)) { |
|
| 208 | + foreach (self::$_ee_message_type_registry as $mt_reg) { |
|
| 209 | + if (empty($mt_reg['autoloadpaths'])) { |
|
| 210 | 210 | continue; |
| 211 | 211 | } |
| 212 | - $paths = array_merge( $paths, $mt_reg['autoloadpaths'] ); |
|
| 212 | + $paths = array_merge($paths, $mt_reg['autoloadpaths']); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | return $paths; |
@@ -228,18 +228,18 @@ discard block |
||
| 228 | 228 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
| 229 | 229 | * @return array |
| 230 | 230 | */ |
| 231 | - public static function register_messengers_to_activate_mt_with( $default_types, EE_messenger $messenger ) { |
|
| 232 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
| 231 | + public static function register_messengers_to_activate_mt_with($default_types, EE_messenger $messenger) { |
|
| 232 | + if (empty(self::$_ee_message_type_registry)) { |
|
| 233 | 233 | return $default_types; |
| 234 | 234 | } |
| 235 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
| 236 | - if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
| 235 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
| 236 | + if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) { |
|
| 237 | 237 | continue; |
| 238 | 238 | } |
| 239 | 239 | // loop through each of the messengers and if it matches the loaded class |
| 240 | 240 | // then we add this message type to the |
| 241 | - foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) { |
|
| 242 | - if ( $messenger->name == $msgr ) { |
|
| 241 | + foreach ($mt_reg['messengers_to_activate_with'] as $msgr) { |
|
| 242 | + if ($messenger->name == $msgr) { |
|
| 243 | 243 | $default_types[] = $message_type_name; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -259,18 +259,18 @@ discard block |
||
| 259 | 259 | * @param EE_messenger $messenger The EE_messenger the filter is called from. |
| 260 | 260 | * @return array |
| 261 | 261 | */ |
| 262 | - public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
|
| 263 | - if ( empty( self::$_ee_message_type_registry ) ) { |
|
| 262 | + public static function register_messengers_to_validate_mt_with($valid_types, EE_messenger $messenger) { |
|
| 263 | + if (empty(self::$_ee_message_type_registry)) { |
|
| 264 | 264 | return $valid_types; |
| 265 | 265 | } |
| 266 | - foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) { |
|
| 267 | - if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) { |
|
| 266 | + foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) { |
|
| 267 | + if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) { |
|
| 268 | 268 | continue; |
| 269 | 269 | } |
| 270 | 270 | // loop through each of the messengers and if it matches the loaded class |
| 271 | 271 | // then we add this message type to the |
| 272 | - foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) { |
|
| 273 | - if ( $messenger->name == $msgr ) { |
|
| 272 | + foreach ($mt_reg['messengers_to_validate_with'] as $msgr) { |
|
| 273 | + if ($messenger->name == $msgr) { |
|
| 274 | 274 | $valid_types[] = $message_type_name; |
| 275 | 275 | } |
| 276 | 276 | } |
@@ -251,14 +251,14 @@ |
||
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | /** |
| 254 | - * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
| 255 | - * |
|
| 256 | - * @since 4.3.0 |
|
| 257 | - * @param array $valid_types array of message types valid with messenger ( |
|
| 258 | - * corresponds to the $name property of message type) |
|
| 259 | - * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
| 260 | - * @return array |
|
| 261 | - */ |
|
| 254 | + * callback for FHEE__EE_messenger__get_valid_message_types__default_types filter. |
|
| 255 | + * |
|
| 256 | + * @since 4.3.0 |
|
| 257 | + * @param array $valid_types array of message types valid with messenger ( |
|
| 258 | + * corresponds to the $name property of message type) |
|
| 259 | + * @param EE_messenger $messenger The EE_messenger the filter is called from. |
|
| 260 | + * @return array |
|
| 261 | + */ |
|
| 262 | 262 | public static function register_messengers_to_validate_mt_with( $valid_types, EE_messenger $messenger ) { |
| 263 | 263 | if ( empty( self::$_ee_message_type_registry ) ) { |
| 264 | 264 | return $valid_types; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed $info |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function add( $object, $info = null ) { |
|
| 43 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | - return parent::add( $object, $info ); |
|
| 42 | + public function add($object, $info = null) { |
|
| 43 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | + return parent::add($object, $info); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param mixed $info |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public function set_info( $object, $info = null ) { |
|
| 61 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | - return parent::set_info( $object, $info ); |
|
| 60 | + public function set_info($object, $info = null) { |
|
| 61 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | + return parent::set_info($object, $info); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param mixed |
| 75 | 75 | * @return null | object |
| 76 | 76 | */ |
| 77 | - public function get_by_info( $info ) { |
|
| 78 | - return parent::get_by_info( str_replace( ' ', '_', strtolower( $info ) ) ); |
|
| 77 | + public function get_by_info($info) { |
|
| 78 | + return parent::get_by_info(str_replace(' ', '_', strtolower($info))); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | * @param object $object |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function has( $object ) { |
|
| 93 | - return parent::has( $object ); |
|
| 92 | + public function has($object) { |
|
| 93 | + return parent::has($object); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $message_type_name |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - public function has_by_name( $message_type_name ) { |
|
| 108 | - return $this->get_by_info( $message_type_name ) instanceof $this->interface ? true : false; |
|
| 107 | + public function has_by_name($message_type_name) { |
|
| 108 | + return $this->get_by_info($message_type_name) instanceof $this->interface ? true : false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param $object |
| 120 | 120 | * @return bool |
| 121 | 121 | */ |
| 122 | - public function remove( $object ) { |
|
| 123 | - return parent::remove( $object ); |
|
| 122 | + public function remove($object) { |
|
| 123 | + return parent::remove($object); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -134,8 +134,8 @@ discard block |
||
| 134 | 134 | * @param $object |
| 135 | 135 | * @return void |
| 136 | 136 | */ |
| 137 | - public function set_current( $object ) { |
|
| 138 | - parent::set_current( $object ); |
|
| 137 | + public function set_current($object) { |
|
| 138 | + parent::set_current($object); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | * @param $info |
| 150 | 150 | * @return void |
| 151 | 151 | */ |
| 152 | - public function set_current_by_info( $info ) { |
|
| 153 | - parent::set_current_by_info( $info ); |
|
| 152 | + public function set_current_by_info($info) { |
|
| 153 | + parent::set_current_by_info($info); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | |
@@ -164,10 +164,10 @@ discard block |
||
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | 166 | public function show_collection_classes() { |
| 167 | - if ( WP_DEBUG ) { |
|
| 167 | + if (WP_DEBUG) { |
|
| 168 | 168 | $this->rewind(); |
| 169 | - while ( $this->valid() ) { |
|
| 170 | - echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : <span style="color:#E76700">' . $this->getInfo() . '</span></h5>'; |
|
| 169 | + while ($this->valid()) { |
|
| 170 | + echo '<h5 style="color:#2EA2CC;">'.__CLASS__.' class : <span style="color:#E76700">'.$this->getInfo().'</span></h5>'; |
|
| 171 | 171 | $this->next(); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * by calling EE_Object_Collection::set_info() |
| 36 | 36 | * |
| 37 | 37 | * @access public |
| 38 | - * @param object $object |
|
| 39 | - * @param mixed $info |
|
| 38 | + * @param EE_message_type $object |
|
| 39 | + * @param string $info |
|
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | public function add( $object, $info = null ) { |
@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @access public |
| 74 | 74 | * @param mixed |
| 75 | + * @param string $info |
|
| 75 | 76 | * @return null | object |
| 76 | 77 | */ |
| 77 | 78 | public function get_by_info( $info ) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | * @param mixed $info |
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | - public function add( $object, $info = null ) { |
|
| 43 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | - return parent::add( $object, $info ); |
|
| 42 | + public function add($object, $info = null) { |
|
| 43 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 44 | + return parent::add($object, $info); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | * @param mixed $info |
| 58 | 58 | * @return bool |
| 59 | 59 | */ |
| 60 | - public function set_info( $object, $info = null ) { |
|
| 61 | - $info = empty( $info ) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | - return parent::set_info( $object, $info ); |
|
| 60 | + public function set_info($object, $info = null) { |
|
| 61 | + $info = empty($info) && $object instanceof $this->interface ? $object->name : $info; |
|
| 62 | + return parent::set_info($object, $info); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | * @param mixed |
| 75 | 75 | * @return null | object |
| 76 | 76 | */ |
| 77 | - public function get_by_info( $info ) { |
|
| 78 | - return parent::get_by_info( str_replace( ' ', '_', strtolower( $info ) ) ); |
|
| 77 | + public function get_by_info($info) { |
|
| 78 | + return parent::get_by_info(str_replace(' ', '_', strtolower($info))); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | * @param object $object |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - public function has( $object ) { |
|
| 93 | - return parent::has( $object ); |
|
| 92 | + public function has($object) { |
|
| 93 | + return parent::has($object); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | * @param string $messenger_name |
| 105 | 105 | * @return bool |
| 106 | 106 | */ |
| 107 | - public function has_by_name( $messenger_name ) { |
|
| 108 | - return $this->get_by_info( $messenger_name ) instanceof $this->interface ? true : false; |
|
| 107 | + public function has_by_name($messenger_name) { |
|
| 108 | + return $this->get_by_info($messenger_name) instanceof $this->interface ? true : false; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | |
@@ -119,8 +119,8 @@ discard block |
||
| 119 | 119 | * @param $object |
| 120 | 120 | * @return bool |
| 121 | 121 | */ |
| 122 | - public function remove( $object ) { |
|
| 123 | - return parent::remove( $object ); |
|
| 122 | + public function remove($object) { |
|
| 123 | + return parent::remove($object); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | * @param $object |
| 149 | 149 | * @return void |
| 150 | 150 | */ |
| 151 | - public function set_current( $object ) { |
|
| 152 | - parent::set_current( $object ); |
|
| 151 | + public function set_current($object) { |
|
| 152 | + parent::set_current($object); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | |
@@ -163,8 +163,8 @@ discard block |
||
| 163 | 163 | * @param $info |
| 164 | 164 | * @return void |
| 165 | 165 | */ |
| 166 | - public function set_current_by_info( $info ) { |
|
| 167 | - parent::set_current_by_info( $info ); |
|
| 166 | + public function set_current_by_info($info) { |
|
| 167 | + parent::set_current_by_info($info); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @return void |
| 179 | 179 | */ |
| 180 | 180 | public function show_collection_classes() { |
| 181 | - if ( WP_DEBUG ) { |
|
| 181 | + if (WP_DEBUG) { |
|
| 182 | 182 | $this->rewind(); |
| 183 | - while ( $this->valid() ) { |
|
| 184 | - echo '<h5 style="color:#2EA2CC;">' . __CLASS__ . ' class : . <span style="color:#E76700">' . $this->getInfo() . '</span></h5>'; |
|
| 183 | + while ($this->valid()) { |
|
| 184 | + echo '<h5 style="color:#2EA2CC;">'.__CLASS__.' class : . <span style="color:#E76700">'.$this->getInfo().'</span></h5>'; |
|
| 185 | 185 | $this->next(); |
| 186 | 186 | } |
| 187 | 187 | } |
@@ -35,8 +35,8 @@ discard block |
||
| 35 | 35 | * by calling EE_Object_Collection::set_info() |
| 36 | 36 | * |
| 37 | 37 | * @access public |
| 38 | - * @param object $object |
|
| 39 | - * @param mixed $info |
|
| 38 | + * @param EE_messenger $object |
|
| 39 | + * @param string $info |
|
| 40 | 40 | * @return bool |
| 41 | 41 | */ |
| 42 | 42 | public function add( $object, $info = null ) { |
@@ -72,6 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @access public |
| 74 | 74 | * @param mixed |
| 75 | + * @param string $info |
|
| 75 | 76 | * @return null | object |
| 76 | 77 | */ |
| 77 | 78 | public function get_by_info( $info ) { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
| 3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 4 | 4 | exit('NO direct script access allowed'); |
| 5 | 5 | |
| 6 | 6 | /** |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | * @param mixed $data incoming data object|array. Suggested that child classes use type hinting for expected |
| 267 | 267 | * data object. But here parent will be generic because we don't know what's coming in. |
| 268 | 268 | */ |
| 269 | - public function __construct( $data ) { |
|
| 269 | + public function __construct($data) { |
|
| 270 | 270 | $this->_data = $data; |
| 271 | 271 | $this->_setup_data(); |
| 272 | 272 | } |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return mixed The prepped data for db |
| 290 | 290 | */ |
| 291 | - static public function convert_data_for_persistent_storage( $data ) { |
|
| 291 | + static public function convert_data_for_persistent_storage($data) { |
|
| 292 | 292 | return $data; |
| 293 | 293 | } |
| 294 | 294 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | * |
| 305 | 305 | * @return mixed |
| 306 | 306 | */ |
| 307 | - static public function convert_data_from_persistent_storage( $data ) { |
|
| 307 | + static public function convert_data_from_persistent_storage($data) { |
|
| 308 | 308 | return $data; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | protected function _assemble_data() { |
| 332 | 332 | //verify that reg_objs is set |
| 333 | 333 | if ( |
| 334 | - ! is_array( $this->reg_objs ) |
|
| 335 | - && ! reset( $this->reg_objs ) instanceof EE_Registration |
|
| 334 | + ! is_array($this->reg_objs) |
|
| 335 | + && ! reset($this->reg_objs) instanceof EE_Registration |
|
| 336 | 336 | ) { |
| 337 | 337 | throw new EE_Error( |
| 338 | 338 | __( |
@@ -347,82 +347,82 @@ discard block |
||
| 347 | 347 | $answers = $questions = $attendees = $line_items = $registrations = array(); |
| 348 | 348 | $total_ticket_count = 0; |
| 349 | 349 | |
| 350 | - if ( ! empty( $this->reg_objs ) ) { |
|
| 350 | + if ( ! empty($this->reg_objs)) { |
|
| 351 | 351 | $event_attendee_count = array(); |
| 352 | - foreach ( $this->reg_objs as $reg ) { |
|
| 352 | + foreach ($this->reg_objs as $reg) { |
|
| 353 | 353 | //account for filtered registrations by status. |
| 354 | - if ( ! empty( $this->filtered_reg_status ) && $this->filtered_reg_status !== $reg->status_ID() ) { |
|
| 354 | + if ( ! empty($this->filtered_reg_status) && $this->filtered_reg_status !== $reg->status_ID()) { |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | $evt_id = $reg->event_ID(); |
| 359 | 359 | /** @type EE_Ticket $ticket */ |
| 360 | - $ticket = $reg->get_first_related( 'Ticket' ); |
|
| 360 | + $ticket = $reg->get_first_related('Ticket'); |
|
| 361 | 361 | $relateddatetime = $ticket->datetimes(); |
| 362 | 362 | $total_ticket_count++; |
| 363 | - $tickets[ $ticket->ID() ]['ticket'] = $ticket; |
|
| 364 | - $tickets[ $ticket->ID() ]['count'] = is_array( $tickets[ $ticket->ID() ] ) |
|
| 365 | - && isset( $tickets[ $ticket->ID() ]['count'] ) |
|
| 366 | - ? $tickets[ $ticket->ID() ]['count'] + 1 |
|
| 363 | + $tickets[$ticket->ID()]['ticket'] = $ticket; |
|
| 364 | + $tickets[$ticket->ID()]['count'] = is_array($tickets[$ticket->ID()]) |
|
| 365 | + && isset($tickets[$ticket->ID()]['count']) |
|
| 366 | + ? $tickets[$ticket->ID()]['count'] + 1 |
|
| 367 | 367 | : 1; |
| 368 | - $tickets[ $ticket->ID() ]['att_objs'][ $reg->attendee_ID() ] = $reg->attendee(); |
|
| 369 | - $tickets[ $ticket->ID() ]['dtt_objs'] = $relateddatetime; |
|
| 370 | - $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
| 368 | + $tickets[$ticket->ID()]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 369 | + $tickets[$ticket->ID()]['dtt_objs'] = $relateddatetime; |
|
| 370 | + $tickets[$ticket->ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 371 | 371 | $event = $reg->event(); |
| 372 | - $tickets[ $ticket->ID() ]['EE_Event'] = $event; |
|
| 373 | - $evtcache[ $evt_id ] = $event; |
|
| 374 | - $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
| 375 | - $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
| 376 | - $eventsetup[ $evt_id ]['att_objs'][ $reg->attendee_ID() ] = $reg->attendee(); |
|
| 377 | - $event_attendee_count[ $evt_id ] = isset( $event_attendee_count[ $evt_id ] ) |
|
| 378 | - ? $event_attendee_count[ $evt_id ] + 1 |
|
| 372 | + $tickets[$ticket->ID()]['EE_Event'] = $event; |
|
| 373 | + $evtcache[$evt_id] = $event; |
|
| 374 | + $eventsetup[$evt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 375 | + $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 376 | + $eventsetup[$evt_id]['att_objs'][$reg->attendee_ID()] = $reg->attendee(); |
|
| 377 | + $event_attendee_count[$evt_id] = isset($event_attendee_count[$evt_id]) |
|
| 378 | + ? $event_attendee_count[$evt_id] + 1 |
|
| 379 | 379 | : 0; |
| 380 | - $attendees[ $reg->attendee_ID() ]['line_ref'][] = $evt_id; |
|
| 381 | - $attendees[ $reg->attendee_ID() ]['att_obj'] = $reg->attendee(); |
|
| 382 | - $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ] = $reg; |
|
| 380 | + $attendees[$reg->attendee_ID()]['line_ref'][] = $evt_id; |
|
| 381 | + $attendees[$reg->attendee_ID()]['att_obj'] = $reg->attendee(); |
|
| 382 | + $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()] = $reg; |
|
| 383 | 383 | //$attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID(); |
| 384 | - $attendees[ $reg->attendee_ID() ]['attendee_email'] = $reg->attendee() instanceof EE_Attendee |
|
| 384 | + $attendees[$reg->attendee_ID()]['attendee_email'] = $reg->attendee() instanceof EE_Attendee |
|
| 385 | 385 | ? $reg->attendee()->email() |
| 386 | 386 | : ''; |
| 387 | - $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket; |
|
| 388 | - $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ] = $event; |
|
| 387 | + $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket; |
|
| 388 | + $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id] = $event; |
|
| 389 | 389 | |
| 390 | 390 | //registrations |
| 391 | - $registrations[ $reg->ID() ]['tkt_obj'] = $ticket; |
|
| 392 | - $registrations[ $reg->ID() ]['evt_obj'] = $event; |
|
| 393 | - $registrations[ $reg->ID() ]['reg_obj'] = $reg; |
|
| 394 | - $registrations[ $reg->ID() ]['att_obj'] = $reg->attendee(); |
|
| 391 | + $registrations[$reg->ID()]['tkt_obj'] = $ticket; |
|
| 392 | + $registrations[$reg->ID()]['evt_obj'] = $event; |
|
| 393 | + $registrations[$reg->ID()]['reg_obj'] = $reg; |
|
| 394 | + $registrations[$reg->ID()]['att_obj'] = $reg->attendee(); |
|
| 395 | 395 | |
| 396 | 396 | //set up answer objects |
| 397 | - $rel_ans = $reg->get_many_related( 'Answer' ); |
|
| 398 | - foreach ( $rel_ans as $ansid => $answer ) { |
|
| 399 | - if ( ! isset( $questions[ $ansid ] ) ) { |
|
| 400 | - $questions[ $ansid ] = $answer->get_first_related( 'Question' ); |
|
| 397 | + $rel_ans = $reg->get_many_related('Answer'); |
|
| 398 | + foreach ($rel_ans as $ansid => $answer) { |
|
| 399 | + if ( ! isset($questions[$ansid])) { |
|
| 400 | + $questions[$ansid] = $answer->get_first_related('Question'); |
|
| 401 | 401 | } |
| 402 | - $answers[ $ansid ] = $answer; |
|
| 403 | - $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer; |
|
| 402 | + $answers[$ansid] = $answer; |
|
| 403 | + $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - foreach ( $relateddatetime as $dtt_id => $datetime ) { |
|
| 407 | - $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
| 408 | - $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime; |
|
| 406 | + foreach ($relateddatetime as $dtt_id => $datetime) { |
|
| 407 | + $eventsetup[$evt_id]['dtt_objs'][$dtt_id] = $datetime; |
|
| 408 | + $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime; |
|
| 409 | 409 | |
| 410 | - if ( isset( $datetimes[ $dtt_id ] ) ) { |
|
| 410 | + if (isset($datetimes[$dtt_id])) { |
|
| 411 | 411 | continue; //already have this info in the datetimes array. |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - $datetimes[ $dtt_id ]['tkt_objs'][] = $ticket; |
|
| 415 | - $datetimes[ $dtt_id ]['datetime'] = $datetime; |
|
| 416 | - $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ] = $event; |
|
| 417 | - $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg; |
|
| 414 | + $datetimes[$dtt_id]['tkt_objs'][] = $ticket; |
|
| 415 | + $datetimes[$dtt_id]['datetime'] = $datetime; |
|
| 416 | + $datetimes[$dtt_id]['evt_objs'][$evt_id] = $event; |
|
| 417 | + $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg; |
|
| 418 | 418 | } |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | //let's loop through the unique event=>reg items and setup data on them |
| 422 | 422 | |
| 423 | - if ( ! empty( $eventsetup ) ) { |
|
| 424 | - foreach ( $eventsetup as $evt_id => $items ) { |
|
| 425 | - if ( $this->txn instanceof EE_Transaction ) { |
|
| 423 | + if ( ! empty($eventsetup)) { |
|
| 424 | + foreach ($eventsetup as $evt_id => $items) { |
|
| 425 | + if ($this->txn instanceof EE_Transaction) { |
|
| 426 | 426 | $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all( |
| 427 | 427 | array( |
| 428 | 428 | array( |
@@ -435,25 +435,25 @@ discard block |
||
| 435 | 435 | } else { |
| 436 | 436 | $ticket_line_items_for_event = array(); |
| 437 | 437 | } |
| 438 | - $events[ $evt_id ] = array( |
|
| 438 | + $events[$evt_id] = array( |
|
| 439 | 439 | 'ID' => $evt_id, |
| 440 | - 'event' => $evtcache[ $evt_id ], |
|
| 441 | - 'name' => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '', |
|
| 442 | - 'total_attendees' => $event_attendee_count[ $evt_id ], |
|
| 440 | + 'event' => $evtcache[$evt_id], |
|
| 441 | + 'name' => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '', |
|
| 442 | + 'total_attendees' => $event_attendee_count[$evt_id], |
|
| 443 | 443 | 'reg_objs' => $items['reg_objs'], |
| 444 | 444 | 'tkt_objs' => $items['tkt_objs'], |
| 445 | 445 | 'att_objs' => $items['att_objs'], |
| 446 | - 'dtt_objs' => isset( $items['dtt_objs'] ) ? $items['dtt_objs'] : array(), |
|
| 446 | + 'dtt_objs' => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(), |
|
| 447 | 447 | 'line_items' => $ticket_line_items_for_event, |
| 448 | 448 | ); |
| 449 | 449 | |
| 450 | 450 | //make sure the tickets have the line items setup for them. |
| 451 | - foreach ( $ticket_line_items_for_event as $line_id => $line_item ) { |
|
| 452 | - if ( $line_item instanceof EE_Line_Item ) { |
|
| 453 | - $tickets[ $line_item->ticket()->ID() ]['line_item'] = $line_item; |
|
| 454 | - $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children(); |
|
| 455 | - $line_items[ $line_item->ID() ]['children'] = $line_item->children(); |
|
| 456 | - $line_items[ $line_item->ID() ]['EE_Ticket'] = $line_item->ticket(); |
|
| 451 | + foreach ($ticket_line_items_for_event as $line_id => $line_item) { |
|
| 452 | + if ($line_item instanceof EE_Line_Item) { |
|
| 453 | + $tickets[$line_item->ticket()->ID()]['line_item'] = $line_item; |
|
| 454 | + $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children(); |
|
| 455 | + $line_items[$line_item->ID()]['children'] = $line_item->children(); |
|
| 456 | + $line_items[$line_item->ID()]['EE_Ticket'] = $line_item->ticket(); |
|
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | } |
@@ -475,7 +475,7 @@ discard block |
||
| 475 | 475 | $this->total_ticket_count = $total_ticket_count; |
| 476 | 476 | $this->registrations = $registrations; |
| 477 | 477 | |
| 478 | - if ( $this->txn instanceof EE_Transaction ) { |
|
| 478 | + if ($this->txn instanceof EE_Transaction) { |
|
| 479 | 479 | $this->tax_line_items = $this->txn->tax_items(); |
| 480 | 480 | $this->additional_line_items = $this->txn->non_ticket_line_items(); |
| 481 | 481 | $this->payments = $this->txn->payments(); |
@@ -485,10 +485,10 @@ discard block |
||
| 485 | 485 | //let's get just the primary_attendee_data! First we get the primary registration object. |
| 486 | 486 | $primary_reg = $this->txn->primary_registration(); |
| 487 | 487 | // verify |
| 488 | - if ( $primary_reg instanceof EE_Registration ) { |
|
| 488 | + if ($primary_reg instanceof EE_Registration) { |
|
| 489 | 489 | |
| 490 | 490 | // get attendee object |
| 491 | - if ( $primary_reg->attendee() instanceof EE_Attendee ) { |
|
| 491 | + if ($primary_reg->attendee() instanceof EE_Attendee) { |
|
| 492 | 492 | |
| 493 | 493 | //now we can setup the primary_attendee_data array |
| 494 | 494 | $this->primary_attendee_data = array( |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | * @param \EE_Request $request |
| 71 | 71 | * @param \EE_Response $response |
| 72 | 72 | */ |
| 73 | - protected function __construct( EE_Request $request, EE_Response $response ) { |
|
| 73 | + protected function __construct(EE_Request $request, EE_Response $response) { |
|
| 74 | 74 | $this->_request = $request; |
| 75 | 75 | $this->_response = $response; |
| 76 | - add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) ); |
|
| 77 | - do_action( 'EE_Dependency_Map____construct' ); |
|
| 76 | + add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize')); |
|
| 77 | + do_action('EE_Dependency_Map____construct'); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | |
@@ -95,10 +95,10 @@ discard block |
||
| 95 | 95 | * @param \EE_Response $response |
| 96 | 96 | * @return \EE_Dependency_Map instance |
| 97 | 97 | */ |
| 98 | - public static function instance( EE_Request $request = null, EE_Response $response = null ) { |
|
| 98 | + public static function instance(EE_Request $request = null, EE_Response $response = null) { |
|
| 99 | 99 | // check if class object is instantiated, and instantiated properly |
| 100 | - if ( ! self::$_instance instanceof EE_Dependency_Map ) { |
|
| 101 | - self::$_instance = new EE_Dependency_Map( $request, $response ); |
|
| 100 | + if ( ! self::$_instance instanceof EE_Dependency_Map) { |
|
| 101 | + self::$_instance = new EE_Dependency_Map($request, $response); |
|
| 102 | 102 | } |
| 103 | 103 | return self::$_instance; |
| 104 | 104 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | * @param array $dependencies |
| 111 | 111 | * @return boolean |
| 112 | 112 | */ |
| 113 | - public static function register_dependencies( $class, $dependencies ) { |
|
| 114 | - if ( ! isset( self::$_instance->_dependency_map[ $class ] ) ) { |
|
| 115 | - self::$_instance->_dependency_map[ $class ] = (array)$dependencies; |
|
| 113 | + public static function register_dependencies($class, $dependencies) { |
|
| 114 | + if ( ! isset(self::$_instance->_dependency_map[$class])) { |
|
| 115 | + self::$_instance->_dependency_map[$class] = (array) $dependencies; |
|
| 116 | 116 | return true; |
| 117 | 117 | } |
| 118 | 118 | return false; |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | * @return bool |
| 127 | 127 | * @throws \EE_Error |
| 128 | 128 | */ |
| 129 | - public static function register_class_loader( $class_name, $loader = 'load_core' ) { |
|
| 129 | + public static function register_class_loader($class_name, $loader = 'load_core') { |
|
| 130 | 130 | // check that loader method starts with "load_" and exists in EE_Registry |
| 131 | - if ( strpos( $loader, 'load_' ) !== 0 || ! method_exists( 'EE_Registry', $loader ) ) { |
|
| 131 | + if (strpos($loader, 'load_') !== 0 || ! method_exists('EE_Registry', $loader)) { |
|
| 132 | 132 | throw new EE_Error( |
| 133 | 133 | sprintf( |
| 134 | - __( '"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso' ), |
|
| 134 | + __('"%1$s" is not a valid loader method on EE_Registry.', 'event_espresso'), |
|
| 135 | 135 | $loader |
| 136 | 136 | ) |
| 137 | 137 | ); |
| 138 | 138 | } |
| 139 | - if ( ! isset( self::$_instance->_class_loaders[ $class_name ] ) ) { |
|
| 140 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 139 | + if ( ! isset(self::$_instance->_class_loaders[$class_name])) { |
|
| 140 | + self::$_instance->_class_loaders[$class_name] = $loader; |
|
| 141 | 141 | return true; |
| 142 | 142 | } |
| 143 | 143 | return false; |
@@ -160,8 +160,8 @@ discard block |
||
| 160 | 160 | * @param string $class_name |
| 161 | 161 | * @return boolean |
| 162 | 162 | */ |
| 163 | - public function has( $class_name = '' ) { |
|
| 164 | - return isset( $this->_dependency_map[ $class_name ] ) ? true : false; |
|
| 163 | + public function has($class_name = '') { |
|
| 164 | + return isset($this->_dependency_map[$class_name]) ? true : false; |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | * @param string $dependency |
| 174 | 174 | * @return bool |
| 175 | 175 | */ |
| 176 | - public function has_dependency_for_class( $class_name = '', $dependency = '' ) { |
|
| 177 | - return isset( $this->_dependency_map[ $class_name ], $this->_dependency_map[ $class_name ][ $dependency ] ) |
|
| 176 | + public function has_dependency_for_class($class_name = '', $dependency = '') { |
|
| 177 | + return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
|
| 178 | 178 | ? true |
| 179 | 179 | : false; |
| 180 | 180 | } |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | * @param string $dependency |
| 189 | 189 | * @return int |
| 190 | 190 | */ |
| 191 | - public function loading_strategy_for_class_dependency( $class_name = '', $dependency = '' ) { |
|
| 192 | - return $this->has_dependency_for_class( $class_name, $dependency ) |
|
| 193 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 191 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') { |
|
| 192 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 193 | + ? $this->_dependency_map[$class_name][$dependency] |
|
| 194 | 194 | : EE_Dependency_Map::not_registered; |
| 195 | 195 | } |
| 196 | 196 | |
@@ -200,8 +200,8 @@ discard block |
||
| 200 | 200 | * @param string $class_name |
| 201 | 201 | * @return string | Closure |
| 202 | 202 | */ |
| 203 | - public function class_loader( $class_name ) { |
|
| 204 | - return isset( $this->_class_loaders[ $class_name ] ) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 203 | + public function class_loader($class_name) { |
|
| 204 | + return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
@@ -339,17 +339,17 @@ discard block |
||
| 339 | 339 | 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
| 340 | 340 | 'EE_Message_Template_Group_Collection' => 'load_lib', |
| 341 | 341 | 'EE_Messages_Generator' => function() { |
| 342 | - return EE_Registry::instance()->load_lib( 'Messages_Generator', array(), false, false ); |
|
| 342 | + return EE_Registry::instance()->load_lib('Messages_Generator', array(), false, false); |
|
| 343 | 343 | }, |
| 344 | - 'EE_Messages_Template_Defaults' => function( $arguments = array() ) { |
|
| 345 | - return EE_Registry::instance()->load_lib( 'Messages_Template_Defaults', $arguments, false, false ); |
|
| 344 | + 'EE_Messages_Template_Defaults' => function($arguments = array()) { |
|
| 345 | + return EE_Registry::instance()->load_lib('Messages_Template_Defaults', $arguments, false, false); |
|
| 346 | 346 | }, |
| 347 | 347 | //load_model |
| 348 | 348 | 'EEM_Message_Template_Group' => 'load_model', |
| 349 | 349 | 'EEM_Message_Template' => 'load_model', |
| 350 | 350 | //load_helper |
| 351 | 351 | 'EEH_Parse_Shortcodes' => function() { |
| 352 | - if ( EE_Registry::instance()->load_helper( 'Parse_Shortcodes' ) ) { |
|
| 352 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 353 | 353 | return new EEH_Parse_Shortcodes(); |
| 354 | 354 | } |
| 355 | 355 | return null; |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
| 3 | 3 | exit('No direct script access allowed'); |
| 4 | 4 | |
| 5 | 5 | /** |
@@ -24,18 +24,18 @@ discard block |
||
| 24 | 24 | * |
| 25 | 25 | * ------------------------------------------------------------------------ |
| 26 | 26 | */ |
| 27 | -class EE_Year_Input extends EE_Select_Input{ |
|
| 27 | +class EE_Year_Input extends EE_Select_Input { |
|
| 28 | 28 | |
| 29 | - function __construct( $input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0 ){ |
|
| 30 | - if($four_digit_year){ |
|
| 29 | + function __construct($input_settings = array(), $four_digit_year = true, $years_behind = 100, $years_ahead = 0) { |
|
| 30 | + if ($four_digit_year) { |
|
| 31 | 31 | $current_year_int = intval(date('Y')); |
| 32 | - }else{ |
|
| 32 | + } else { |
|
| 33 | 33 | $current_year_int = intval(date('y')); |
| 34 | 34 | } |
| 35 | 35 | $answer_options = array(); |
| 36 | - for( $start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++){ |
|
| 36 | + for ($start = $current_year_int - $years_behind; $start <= ($current_year_int + $years_ahead); $start++) { |
|
| 37 | 37 | $answer_options[$start] = $start; |
| 38 | 38 | } |
| 39 | - parent::__construct( $answer_options, $input_settings ); |
|
| 39 | + parent::__construct($answer_options, $input_settings); |
|
| 40 | 40 | } |
| 41 | 41 | } |
@@ -10,21 +10,21 @@ discard block |
||
| 10 | 10 | * @since 4.6 |
| 11 | 11 | * |
| 12 | 12 | */ |
| 13 | -class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base{ |
|
| 13 | +class EE_Full_HTML_Validation_Strategy extends EE_Validation_Strategy_Base { |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @param null $validation_error_message |
| 17 | 17 | */ |
| 18 | - public function __construct( $validation_error_message = NULL ) { |
|
| 19 | - if ( ! $validation_error_message ) { |
|
| 18 | + public function __construct($validation_error_message = NULL) { |
|
| 19 | + if ( ! $validation_error_message) { |
|
| 20 | 20 | global $allowedposttags; |
| 21 | 21 | $validation_error_message = sprintf( |
| 22 | - __( 'Only the following HTML tags are allowed:%1$s%2$s', "event_espresso" ), |
|
| 22 | + __('Only the following HTML tags are allowed:%1$s%2$s', "event_espresso"), |
|
| 23 | 23 | '<br />', |
| 24 | - implode( ",", array_keys( $allowedposttags ) ) |
|
| 24 | + implode(",", array_keys($allowedposttags)) |
|
| 25 | 25 | ); |
| 26 | 26 | } |
| 27 | - parent::__construct( $validation_error_message ); |
|
| 27 | + parent::__construct($validation_error_message); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | |
@@ -38,8 +38,8 @@ discard block |
||
| 38 | 38 | */ |
| 39 | 39 | public function get_list_of_allowed_tags() { |
| 40 | 40 | global $allowedposttags; |
| 41 | - ksort( $allowedposttags ); |
|
| 42 | - return implode( ', ', array_keys( $allowedposttags ) ); |
|
| 41 | + ksort($allowedposttags); |
|
| 42 | + return implode(', ', array_keys($allowedposttags)); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function validate($normalized_value) { |
| 52 | 52 | global $allowedposttags; |
| 53 | - parent::validate( $normalized_value ); |
|
| 54 | - $normalized_value_sans_tags = wp_kses( "$normalized_value", $allowedposttags ); |
|
| 55 | - if ( strlen( $normalized_value ) > strlen( $normalized_value_sans_tags ) ) { |
|
| 56 | - throw new EE_Validation_Error( $this->get_validation_error_message(), 'complex_html_tags' ); |
|
| 53 | + parent::validate($normalized_value); |
|
| 54 | + $normalized_value_sans_tags = wp_kses("$normalized_value", $allowedposttags); |
|
| 55 | + if (strlen($normalized_value) > strlen($normalized_value_sans_tags)) { |
|
| 56 | + throw new EE_Validation_Error($this->get_validation_error_message(), 'complex_html_tags'); |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | \ No newline at end of file |