Completed
Branch FET-8162-relation-exists (8f4753)
by
unknown
32:32 queued 23:52
created
core/libraries/messages/EE_message_type.lib.php 4 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
 
383 383
 
384 384
 	/**
385
-	* This sets up any action/filter hooks this message type puts in place for a specific messenger.  It's called from the set_messages() method.  Note that by default this does nothing.  Child classes will need to override if they want to add specific hooks for a messenger.
386
-	*
387
-	* @since 1.0.0
388
-	*
389
-	* @return void
390
-	*/
385
+	 * This sets up any action/filter hooks this message type puts in place for a specific messenger.  It's called from the set_messages() method.  Note that by default this does nothing.  Child classes will need to override if they want to add specific hooks for a messenger.
386
+	 *
387
+	 * @since 1.0.0
388
+	 *
389
+	 * @return void
390
+	 */
391 391
 	protected function _do_messenger_hooks() {
392 392
 		return;
393 393
 	}
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 			//make sure non admin context does not include the event_author shortcodes
690 690
 			if ( $context != 'admin' ) {
691 691
 				if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) {
692
-				    unset($this->_valid_shortcodes[$context][$key]);
692
+					unset($this->_valid_shortcodes[$context][$key]);
693 693
 				}
694 694
 			}
695 695
 		}
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 		//make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context.
698 698
 		if ( !empty( $this->_valid_shortcodes['admin'] ) ) {
699 699
 			if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) {
700
-				    unset($this->_valid_shortcodes['admin'][$key]);
700
+					unset($this->_valid_shortcodes['admin'][$key]);
701 701
 				}
702 702
 			//make sure admin context does not include the recipient_details shortcodes
703 703
 			if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) {
704
-				    unset($this->_valid_shortcodes['admin'][$key]);
704
+					unset($this->_valid_shortcodes['admin'][$key]);
705 705
 				}
706 706
 		}
707 707
 	}
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @param  EE_messenger $active_messenger The active messenger being used
260 260
 	 * @param  string $context if present then a message is only being generated for a specific context
261 261
 	 * @param  bool   $preview indicate whether a preview is being generated or not.
262
-	 * @return void
262
+	 * @return false|null
263 263
 	 */
264 264
 	public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) {
265 265
 
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 	 * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages)
502 502
 	 * @param array $extra  This is just an extra argument that can be used to pass additional data for setting up page content.
503 503
 	 * @access public
504
-	 * @return void
504
+	 * @return string
505 505
 	 */
506 506
 	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) {
507 507
 		//we can also further refine the context by action (if present).
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	 * The main purpose of this function is to setup the various parameters within the message_type.  $this->addressees, $this->_templates, $this->count, and any extra stuff to the data object that can come from the message_type template options.
561 561
 	 * Child classes might overwrite this if they aren't expecting EE_Session as the incoming data object.
562 562
 	 *
563
-	 * @return void
563
+	 * @return boolean
564 564
 	 * @access protected
565 565
 	 */
566 566
 	protected function _init_data() {
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 
603 603
 	/**
604 604
 	 * processes the data object so we get
605
-	 * @return void
605
+	 * @return boolean
606 606
 	 */
607 607
 	protected function _process_data() {
608 608
 		//at a minimum, we NEED EE_Attendee objects.
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 * Takes care of setting up the addressee object(s) for the primary attendee.
754 754
 	 *
755 755
 	 * @access protected
756
-	 * @return array of EE_Addressee objects
756
+	 * @return EE_Messages_Addressee[] of EE_Addressee objects
757 757
 	 */
758 758
 	protected function _primary_attendee_addressees() {
759 759
 		$aee = $this->_default_addressee_data;
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @param  bool   $preview indicate whether a preview is being generated or not.
262 262
 	 * @return void
263 263
 	 */
264
-	public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) {
264
+	public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE) {
265 265
 
266 266
 		$this->_active_messenger = $active_messenger;
267 267
 
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 
271 271
 		//this is a special method that allows child message types to trigger an exit from generating messages early (in cases where there may be a delay on send).
272 272
 		$exit = $this->_trigger_exit();
273
-		if ( $exit && ! $this->_preview ) return FALSE;
273
+		if ($exit && ! $this->_preview) return FALSE;
274 274
 
275 275
 		//todo: need to move require into registration hook but for now we'll require here.
276
-		EE_Registry::instance()->load_helper( 'Parse_Shortcodes' );
276
+		EE_Registry::instance()->load_helper('Parse_Shortcodes');
277 277
 		//get shortcode_replace instance- set when _get_messages is called in child...
278 278
 		$this->_shortcode_replace = new EEH_Parse_Shortcodes();
279 279
 
@@ -284,9 +284,9 @@  discard block
 block discarded – undo
284 284
 		$this->_data_handler = ! $this->_preview ? $this->_data_handler : 'Preview';
285 285
 
286 286
 		//if there is an incoming context then this is a preview so let's ONLY show the given context!
287
-		if ( !empty( $context ) ) {
288
-			$cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : '';
289
-			if ( ! empty( $cntxt )  ) {
287
+		if ( ! empty($context)) {
288
+			$cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
289
+			if ( ! empty($cntxt)) {
290 290
 				$this->_contexts = array();
291 291
 				$this->_contexts[$context] = $cntxt;
292 292
 			}
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 		$exit = $this->_init_data();
296 296
 
297 297
 		//final check for if we exit or not cause child objects may have run conditionals that cleared out data so no addresees generated.
298
-		if ( $exit ) return FALSE;
298
+		if ($exit) return FALSE;
299 299
 
300 300
 		$this->_get_templates(); //get the templates that have been set with this type and for the given messenger that have been saved in the database.
301 301
 		$this->_assemble_messages();
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	 * @param int      $id 		Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object
332 332
 	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
333 333
 	 */
334
-	abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id );
334
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
335 335
 
336 336
 
337 337
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 *
364 364
 	 * @return int
365 365
 	 */
366
-	protected function _get_id_for_msg_url( $context, EE_Registration $registration ) {
366
+	protected function _get_id_for_msg_url($context, EE_Registration $registration) {
367 367
 		return 0;
368 368
 	}
369 369
 
@@ -396,28 +396,28 @@  discard block
 block discarded – undo
396 396
 	 *
397 397
 	 * @return string          generated url
398 398
 	 */
399
-	public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) {
399
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) {
400 400
 
401 401
 		//validate context
402 402
 		//valid context?
403
-		if ( !isset( $this->_contexts[$context] ) ) {
404
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
403
+		if ( ! isset($this->_contexts[$context])) {
404
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
405 405
 		}
406 406
 
407 407
 		//valid sending_messenger?
408 408
 		$not_valid_msgr = FALSE;
409
-		foreach ( $this->_with_messengers as $generating => $sendings ) {
410
-			if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) {
409
+		foreach ($this->_with_messengers as $generating => $sendings) {
410
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) {
411 411
 				$not_valid_msgr = TRUE;
412 412
 			}
413 413
 		}
414 414
 
415
-		if ( $not_valid_msgr ) {
416
-			throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) );
415
+		if ($not_valid_msgr) {
416
+			throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this)));
417 417
 		}
418 418
 
419 419
 		EE_Registry::instance()->load_helper('MSG_Template');
420
-		return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) );
420
+		return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration));
421 421
 	}
422 422
 
423 423
 
@@ -438,19 +438,19 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @return mixed (EE_Base_Class||EE_Base_Class[])
440 440
 	 */
441
-	public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) {
441
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0) {
442 442
 		//valid context?
443
-		if ( !isset( $this->_contexts[$context] ) ) {
444
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
443
+		if ( ! isset($this->_contexts[$context])) {
444
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
445 445
 		}
446 446
 
447 447
 		//get data and apply global and class specific filters on it.
448
-		$data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this );
449
-		$data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this );
448
+		$data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this);
449
+		$data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
450 450
 
451 451
 		//if empty then something went wrong!
452
-		if ( empty( $data ) ) {
453
-			throw new EE_Error( sprintf(  __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) );
452
+		if (empty($data)) {
453
+			throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name));
454 454
 		}
455 455
 
456 456
 		return $data;
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 */
486 486
 	public function with_messengers() {
487 487
 
488
-		return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers);
488
+		return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers);
489 489
 	}
490 490
 
491 491
 
@@ -503,9 +503,9 @@  discard block
 block discarded – undo
503 503
 	 * @access public
504 504
 	 * @return void
505 505
 	 */
506
-	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) {
506
+	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) {
507 507
 		//we can also further refine the context by action (if present).
508
-		return $this->_get_admin_page_content( $page, $action, $extra, $messengers );
508
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
509 509
 	}
510 510
 
511 511
 
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 */
550 550
 	public function get_master_templates() {
551 551
 		//first class specific filter then filter that by the global filter.
552
-		$master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates );
553
-		return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this );
552
+		$master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates);
553
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
554 554
 	}
555 555
 
556 556
 
@@ -568,31 +568,31 @@  discard block
 block discarded – undo
568 568
 		/**
569 569
 		 * first let's make sure that incoming data isn't empty!
570 570
 		 */
571
-		if ( is_array($this->_data) && empty($this->_data) && !$this->_preview ) {
572
-			$msg = sprintf( __( '"%s" message type incoming data is empty.  There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular'] );
573
-			throw new EE_Error( $msg );
571
+		if (is_array($this->_data) && empty($this->_data) && ! $this->_preview) {
572
+			$msg = sprintf(__('"%s" message type incoming data is empty.  There is nothing to work with so why are you bugging me?', 'event_espresso'), $this->label['singular']);
573
+			throw new EE_Error($msg);
574 574
 		}
575 575
 
576
-		if ( empty( $this->_data_handler) ) {
577
-			$msg = sprintf( __('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__ );
578
-			throw new EE_Error( $msg );
576
+		if (empty($this->_data_handler)) {
577
+			$msg = sprintf(__('Hey %s hasn\'t declared a handler for the incoming data, so I\'m stuck', 'event_espresso'), __CLASS__);
578
+			throw new EE_Error($msg);
579 579
 		}
580 580
 
581 581
 
582 582
 		//setup class name for the data handler
583
-		$classname = 'EE_Messages_' . $this->_data_handler . '_incoming_data';
583
+		$classname = 'EE_Messages_'.$this->_data_handler.'_incoming_data';
584 584
 
585 585
 		//check that the class exists
586
-		if ( !class_exists( $classname ) ) {
586
+		if ( ! class_exists($classname)) {
587 587
 
588 588
 			$msg[] = __('uhoh, Something went wrong and no data handler is found', 'event_espresso');
589
-			$msg[] = sprintf( __('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class").  Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname );
590
-			throw new EE_error( implode('||', $msg) );
589
+			$msg[] = sprintf(__('The %s class has set the "$_data_handler" property but the string included (%s) does not match any existing "EE_Messages_incoming_data" classes (found in "/includes/core/messages/data_class").  Looking for %s.', 'event_espresso'), __CLASS__, $this->_data_handler, $classname);
590
+			throw new EE_error(implode('||', $msg));
591 591
 		}
592 592
 
593 593
 		//k lets get the prepared data object and replace existing data property with it.
594
-		$a = new ReflectionClass( $classname );
595
-		$this->_data = $a->newInstance( $this->_data );
594
+		$a = new ReflectionClass($classname);
595
+		$this->_data = $a->newInstance($this->_data);
596 596
 
597 597
 		$this->_set_default_addressee_data();
598 598
 		return $this->_process_data();
@@ -607,15 +607,15 @@  discard block
 block discarded – undo
607 607
 	protected function _process_data() {
608 608
 		//at a minimum, we NEED EE_Attendee objects.
609 609
 
610
-		if ( empty( $this->_data->attendees ) )
611
-			return TRUE;  //EXIT!
610
+		if (empty($this->_data->attendees))
611
+			return TRUE; //EXIT!
612 612
 
613 613
 		//process addressees for each context.  Child classes will have to have methods for each context defined to handle the processing of the data object within them
614
-		foreach ( $this->_contexts as $context => $details ) {
615
-			$xpctd_method = '_' . $context . '_addressees';
616
-			if ( !method_exists( $this, $xpctd_method ) )
617
-				throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
618
-			 $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) );
614
+		foreach ($this->_contexts as $context => $details) {
615
+			$xpctd_method = '_'.$context.'_addressees';
616
+			if ( ! method_exists($this, $xpctd_method))
617
+				throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method));
618
+			 $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
619 619
 		}
620 620
 		return FALSE; //DON'T EXIT
621 621
 	}
@@ -650,8 +650,8 @@  discard block
 block discarded – undo
650 650
 			'total_ticket_count' => $this->_data->total_ticket_count
651 651
 			);
652 652
 
653
-		if ( is_array( $this->_data->primary_attendee_data ) ) {
654
-			$this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data );
653
+		if (is_array($this->_data->primary_attendee_data)) {
654
+			$this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data);
655 655
 			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
656 656
 			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
657 657
 		}
@@ -669,26 +669,26 @@  discard block
 block discarded – undo
669 669
 	 * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default).
670 670
 	 */
671 671
 	protected function _set_valid_shortcodes() {
672
-		$all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' );
672
+		$all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger');
673 673
 		$contexts = $this->get_contexts();
674
-		foreach ( $contexts as $context => $details ) {
674
+		foreach ($contexts as $context => $details) {
675 675
 			$this->_valid_shortcodes[$context] = $all_shortcodes;
676 676
 
677 677
 			//make sure non admin context does not include the event_author shortcodes
678
-			if ( $context != 'admin' ) {
679
-				if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) {
678
+			if ($context != 'admin') {
679
+				if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
680 680
 				    unset($this->_valid_shortcodes[$context][$key]);
681 681
 				}
682 682
 			}
683 683
 		}
684 684
 
685 685
 		//make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context.
686
-		if ( !empty( $this->_valid_shortcodes['admin'] ) ) {
687
-			if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) {
686
+		if ( ! empty($this->_valid_shortcodes['admin'])) {
687
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
688 688
 				    unset($this->_valid_shortcodes['admin'][$key]);
689 689
 				}
690 690
 			//make sure admin context does not include the recipient_details shortcodes
691
-			if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) {
691
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
692 692
 				    unset($this->_valid_shortcodes['admin'][$key]);
693 693
 				}
694 694
 		}
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
 	 * @param  array  $new_config array of valid shortcodes (by context)
702 702
 	 * @return void               sets valid_shortcodes property
703 703
 	 */
704
-	public function reset_valid_shortcodes_config( $new_config ) {
705
-		foreach ( $new_config as $context => $shortcodes ) {
704
+	public function reset_valid_shortcodes_config($new_config) {
705
+		foreach ($new_config as $context => $shortcodes) {
706 706
 			$this->_valid_shortcodes[$context] = $shortcodes;
707 707
 		}
708 708
 	}
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 		$addressees = array();
723 723
 
724 724
 		//first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user.
725
-		foreach ( $this->_data->events as $line_ref => $event ) {
725
+		foreach ($this->_data->events as $line_ref => $event) {
726 726
 			$admin_id = $this->_get_event_admin_id($event['ID']);
727 727
 			//get the user_id for the event
728 728
 			$admin_ids[] = $admin_id;
@@ -734,14 +734,14 @@  discard block
 block discarded – undo
734 734
 		$admin_ids = array_unique($admin_ids);
735 735
 
736 736
 		//k now we can loop through the event_admins and setup the addressee data.
737
-		foreach ( $admin_ids as $event_admin ) {
737
+		foreach ($admin_ids as $event_admin) {
738 738
 			$aee = array(
739 739
 				'user_id' => $event_admin,
740 740
 				'events' => $admin_events[$event_admin],
741 741
 				'attendees' => $this->_data->attendees
742 742
 				);
743
-			$aee = array_merge( $this->_default_addressee_data, $aee );
744
-			$addressees[] = new EE_Messages_Addressee( $aee );
743
+			$aee = array_merge($this->_default_addressee_data, $aee);
744
+			$addressees[] = new EE_Messages_Addressee($aee);
745 745
 		}
746 746
 
747 747
 		return $addressees;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		$aee['attendees'] = $this->_data->attendees;
762 762
 
763 763
 		//great now we can instantiate the $addressee object and return (as an array);
764
-		$add[] = new EE_Messages_Addressee( $aee );
764
+		$add[] = new EE_Messages_Addressee($aee);
765 765
 		return $add;
766 766
 	}
767 767
 
@@ -779,26 +779,26 @@  discard block
 block discarded – undo
779 779
 		//we just have to loop through the attendees.  We'll also set the attached events for each attendee.
780 780
 		//use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
781 781
 		$already_processed = array();
782
-		foreach ( $this->_data->attendees as $att_id => $details ) {
782
+		foreach ($this->_data->attendees as $att_id => $details) {
783 783
 			//set the attendee array to blank on each loop;
784 784
 			$aee = array();
785 785
 
786
-			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue;
786
+			if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue;
787 787
 
788
-			if ( in_array( $details['attendee_email'], $already_processed ) )
788
+			if (in_array($details['attendee_email'], $already_processed))
789 789
 				continue;
790 790
 
791 791
 			$already_processed[] = $details['attendee_email'];
792 792
 
793
-			foreach ( $details as $item => $value ) {
793
+			foreach ($details as $item => $value) {
794 794
 				$aee[$item] = $value;
795
-				if ( $item == 'line_ref' ) {
796
-					foreach ( $value as $event_id ) {
795
+				if ($item == 'line_ref') {
796
+					foreach ($value as $event_id) {
797 797
 						$aee['events'][$event_id] = $this->_data->events[$event_id];
798 798
 					}
799 799
 				}
800 800
 
801
-				if ( $item == 'attendee_email' ) {
801
+				if ($item == 'attendee_email') {
802 802
 					$aee['attendee_email'] = $value;
803 803
 				}
804 804
 
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 			$aee['attendees'] = $this->_data->attendees;
814 814
 
815 815
 			//merge in the primary attendee data
816
-			$aee = array_merge( $this->_default_addressee_data, $aee );
817
-			$add[] = new EE_Messages_Addressee( $aee );
816
+			$aee = array_merge($this->_default_addressee_data, $aee);
817
+			$add[] = new EE_Messages_Addressee($aee);
818 818
 		}
819 819
 
820 820
 		return $add;
@@ -839,43 +839,43 @@  discard block
 block discarded – undo
839 839
 		);
840 840
 
841 841
 		//in vanilla EE we're assuming there's only one event.  However, if there are multiple events then we'll just use the default templates instead of different templates per event (which could create problems).
842
-		if ( count($this->_data->events) === 1 ) {
843
-			foreach ( $this->_data->events as $event ) {
842
+		if (count($this->_data->events) === 1) {
843
+			foreach ($this->_data->events as $event) {
844 844
 				$EVT_ID = $event['ID'];
845 845
 			}
846 846
 		}
847 847
 		// is there a Group ID in the incoming request?
848
-		EE_Registry::instance()->load_core( 'Request_Handler' );
848
+		EE_Registry::instance()->load_core('Request_Handler');
849 849
 		// if not, set a default value of false
850
-		$GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID', false );
850
+		$GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID', false);
851 851
 		//if this is a preview then we just get whatever message group is for the preview and skip this part!
852
-		if ( $this->_preview && $GRP_ID ) {
853
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
852
+		if ($this->_preview && $GRP_ID) {
853
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
854 854
 		} else {
855 855
 			//not a preview or test send so lets continue on our way!
856 856
 			//is there an evt_id?  If so let's get that. template.
857
-			if ( !empty( $EVT_ID )  ) {
857
+			if ( ! empty($EVT_ID)) {
858 858
 				$evt_qa = array(
859 859
 					'Event.EVT_ID' => $EVT_ID
860 860
 				);
861
-				$qa = array_merge( $template_qa, $evt_qa );
862
-				$mtpg = EEM_Message_Template_Group::instance()->get_one( array( $qa ) );
861
+				$qa = array_merge($template_qa, $evt_qa);
862
+				$mtpg = EEM_Message_Template_Group::instance()->get_one(array($qa));
863 863
 			}
864 864
 
865 865
 			//is there a 'GRP_ID' ? if so let's get that.
866 866
 
867 867
 			//if global template is NOT an override, and there is a 'GRP_ID' in the request, then we'll assume a specific template has ben requested.
868
-			if ( $GRP_ID ) {
869
-				$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
868
+			if ($GRP_ID) {
869
+				$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
870 870
 			}
871 871
 
872 872
 
873 873
 			$template_qa['MTP_is_global'] = TRUE;
874 874
 
875 875
 			//this gets the current global template (message template group) for the active messenger and message type.
876
-			$global_mtpg = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
876
+			$global_mtpg = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
877 877
 
878
-			$mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get( 'MTP_is_override' ) ? $mtpg : $global_mtpg;
878
+			$mtpg = $mtpg instanceof EE_Message_Template_Group && ! $global_mtpg->get('MTP_is_override') ? $mtpg : $global_mtpg;
879 879
 		}
880 880
 
881 881
 		$this->_GRP_ID = $mtpg->ID();
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 
889 889
 
890 890
 
891
-		foreach ( $templates as $context => $template_fields ) {
892
-			foreach( $template_fields as $template_field=> $template_obj ) {
891
+		foreach ($templates as $context => $template_fields) {
892
+			foreach ($template_fields as $template_field=> $template_obj) {
893 893
 				$this->_templates[$template_field][$context] = $template_obj->get('MTP_content');
894 894
 			}
895 895
 		}
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
 	protected function _assemble_messages() {
905 905
 		//make sure any set messages object is cleared
906 906
 		$this->messages = array();
907
-		foreach ( $this->_addressees as $context => $addressees ) {
908
-			foreach ( $addressees as $addressee ) {
907
+		foreach ($this->_addressees as $context => $addressees) {
908
+			foreach ($addressees as $addressee) {
909 909
 				$message = $this->_setup_message_object($context, $addressee);
910 910
 				//only assign message if everything went okay
911
-				if ( $message ) {
911
+				if ($message) {
912 912
 					$message->template_pack = $this->_template_pack;
913 913
 					$message->variation = $this->_variation;
914 914
 					$this->messages[] = $message;
@@ -932,16 +932,16 @@  discard block
 block discarded – undo
932 932
 		$m_shortcodes = $this->_active_messenger->get_valid_shortcodes();
933 933
 
934 934
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because this context is turned off) EXCEPT if we're previewing
935
-		if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview )
935
+		if ((isset($this->_templates['to'][$context]) && empty($this->_templates['to'][$context])) && ! $this->_preview)
936 936
 			return false;
937 937
 
938
-		foreach ( $this->_templates as $field => $ctxt ) {
938
+		foreach ($this->_templates as $field => $ctxt) {
939 939
 			//let's setup the valid shortcodes for the incoming context.
940 940
 			$valid_shortcodes = $mt_shortcodes[$context];
941 941
 			//merge in valid shortcodes for the field.
942 942
 			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
943
-			if ( isset( $this->_templates[$field][$context] ) ) {
944
-				$message->$field = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID );
943
+			if (isset($this->_templates[$field][$context])) {
944
+				$message->$field = $this->_shortcode_replace->parse_message_template($this->_templates[$field][$context], $addressee, $shortcodes, $this, $this->_active_messenger, $context, $this->_GRP_ID);
945 945
 			}
946 946
 		}
947 947
 		return $message;
Please login to merge, or discard this patch.
Braces   +24 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
@@ -270,7 +271,9 @@  discard block
 block discarded – undo
270 271
 
271 272
 		//this is a special method that allows child message types to trigger an exit from generating messages early (in cases where there may be a delay on send).
272 273
 		$exit = $this->_trigger_exit();
273
-		if ( $exit && ! $this->_preview ) return FALSE;
274
+		if ( $exit && ! $this->_preview ) {
275
+			return FALSE;
276
+		}
274 277
 
275 278
 		//todo: need to move require into registration hook but for now we'll require here.
276 279
 		EE_Registry::instance()->load_helper( 'Parse_Shortcodes' );
@@ -295,7 +298,9 @@  discard block
 block discarded – undo
295 298
 		$exit = $this->_init_data();
296 299
 
297 300
 		//final check for if we exit or not cause child objects may have run conditionals that cleared out data so no addresees generated.
298
-		if ( $exit ) return FALSE;
301
+		if ( $exit ) {
302
+			return FALSE;
303
+		}
299 304
 
300 305
 		$this->_get_templates(); //get the templates that have been set with this type and for the given messenger that have been saved in the database.
301 306
 		$this->_assemble_messages();
@@ -607,14 +612,17 @@  discard block
 block discarded – undo
607 612
 	protected function _process_data() {
608 613
 		//at a minimum, we NEED EE_Attendee objects.
609 614
 
610
-		if ( empty( $this->_data->attendees ) )
611
-			return TRUE;  //EXIT!
615
+		if ( empty( $this->_data->attendees ) ) {
616
+					return TRUE;
617
+		}
618
+		//EXIT!
612 619
 
613 620
 		//process addressees for each context.  Child classes will have to have methods for each context defined to handle the processing of the data object within them
614 621
 		foreach ( $this->_contexts as $context => $details ) {
615 622
 			$xpctd_method = '_' . $context . '_addressees';
616
-			if ( !method_exists( $this, $xpctd_method ) )
617
-				throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
623
+			if ( !method_exists( $this, $xpctd_method ) ) {
624
+							throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
625
+			}
618 626
 			 $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) );
619 627
 		}
620 628
 		return FALSE; //DON'T EXIT
@@ -783,10 +791,13 @@  discard block
 block discarded – undo
783 791
 			//set the attendee array to blank on each loop;
784 792
 			$aee = array();
785 793
 
786
-			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue;
787
-
788
-			if ( in_array( $details['attendee_email'], $already_processed ) )
794
+			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) {
789 795
 				continue;
796
+			}
797
+
798
+			if ( in_array( $details['attendee_email'], $already_processed ) ) {
799
+							continue;
800
+			}
790 801
 
791 802
 			$already_processed[] = $details['attendee_email'];
792 803
 
@@ -932,8 +943,9 @@  discard block
 block discarded – undo
932 943
 		$m_shortcodes = $this->_active_messenger->get_valid_shortcodes();
933 944
 
934 945
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because this context is turned off) EXCEPT if we're previewing
935
-		if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview )
936
-			return false;
946
+		if ( ( isset( $this->_templates['to'][$context] ) && empty( $this->_templates['to'][$context] ) ) && !$this->_preview ) {
947
+					return false;
948
+		}
937 949
 
938 950
 		foreach ( $this->_templates as $field => $ctxt ) {
939 951
 			//let's setup the valid shortcodes for the incoming context.
Please login to merge, or discard this patch.
core/libraries/messages/data_class/EE_Messages_Addressee.class.php 2 patches
Braces   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
4 4
 	exit('NO direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -166,8 +167,9 @@  discard block
 block discarded – undo
166 167
 	protected function _set_properties() {
167 168
 
168 169
 		foreach ( $this->_data as $prop => $value ) {
169
-			if( EEH_Class_Tools::has_property( $this, $prop ) )
170
-				$this->$prop = $value;
170
+			if( EEH_Class_Tools::has_property( $this, $prop ) ) {
171
+							$this->$prop = $value;
172
+			}
171 173
 		}
172 174
 
173 175
 		//if user_id present we'll use this to set the fname and lname and admin_email.
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	/**
35 35
 	 * Identifier properties for the recipient
36 36
 	 */
37
-	public $user_id;  //if available we'll use this to set the fname and lname (admin)
37
+	public $user_id; //if available we'll use this to set the fname and lname (admin)
38 38
 	public $fname; //this will always be the admin fname (set later via incoming user_id)
39 39
 	public $lname; //this will always be the admin lnmae (set later via incoming user_id)
40 40
 	public $primary_registration_id;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @param array $addressee_data We're expecting an incoming array of data that will be used to fill the properties for the object.
120 120
 	 * @return void
121 121
 	 */
122
-	public function __construct( $addressee_data ) {
122
+	public function __construct($addressee_data) {
123 123
 		$this->_data = $addressee_data;
124 124
 		$this->_set_properties();
125 125
 	}
@@ -135,15 +135,15 @@  discard block
 block discarded – undo
135 135
 	 */
136 136
 	protected function _set_properties() {
137 137
 
138
-		foreach ( $this->_data as $prop => $value ) {
139
-			if( EEH_Class_Tools::has_property( $this, $prop ) )
138
+		foreach ($this->_data as $prop => $value) {
139
+			if (EEH_Class_Tools::has_property($this, $prop))
140 140
 				$this->$prop = $value;
141 141
 		}
142 142
 
143 143
 		//if user_id present we'll use this to set the fname and lname and admin_email.
144
-		if ( !empty( $this->user_id ) ) {
144
+		if ( ! empty($this->user_id)) {
145 145
 			$this->user_id = (int) $this->user_id;
146
-			$user = get_userdata( $this->user_id );
146
+			$user = get_userdata($this->user_id);
147 147
 			$this->fname = $user->user_firstname;
148 148
 			$this->lname = $user->user_lastname;
149 149
 			$this->admin_email = $user->user_email;
Please login to merge, or discard this patch.
core/libraries/messages/defaults/EE_Message_Template_Defaults.core.php 2 patches
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @access public
124 124
 	 * @return void
125 125
 	 */
126
-	public function __construct( EE_Messages $messages, $messenger_name, $message_type_name, $GRP_ID = 0 ) {
126
+	public function __construct(EE_Messages $messages, $messenger_name, $message_type_name, $GRP_ID = 0) {
127 127
 		$this->_EE_MSG = $messages;
128 128
 
129 129
 		//set the model object
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
 		$this->_mt_name = $message_type_name;
136 136
 
137 137
 		//make sure required props have been set
138
-		if ( empty( $this->_m_name) || empty( $this->_mt_name ) ) {
138
+		if (empty($this->_m_name) || empty($this->_mt_name)) {
139 139
 			$msg[] = __('Message Templates cannot be generated because the Messenger and Message Types haven\'t been defined for the generator.', 'event_espresso');
140 140
 			$msg[] = __('You need to set the "$m_name" and "$mt_name" properties', 'event_espresso');
141
-			throw new EE_Error( implode( '||', $msg ) );
141
+			throw new EE_Error(implode('||', $msg));
142 142
 		}
143 143
 
144 144
 		$this->_init();
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 * @param string $template_pack This corresponds to a template pack class reference which will contain information about where to obtain the templates.
155 155
 	 * @return void
156 156
 	 */
157
-	final private function _set_templates( $template_pack ) {
157
+	final private function _set_templates($template_pack) {
158 158
 
159 159
 		//get the corresponding template pack object (if present.  If not then we just load the default and add a notice).  The class name should be something like 'EE_Messages_Template_Pack_Default' where "default' would be the incoming template pack reference.
160
-		$class_name = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $template_pack ) ) );
160
+		$class_name = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $template_pack)));
161 161
 
162
-		if ( ! class_exists( $class_name ) ) {
163
-			EE_Error::add_error( sprintf( __('The template pack represented by a class corresponding to "%s" does not exist.  Likely the autoloader for this class has the wrong path or the incoming reference is mispelled.  The default template pack  been used to generate the templates instead.', 'event_espresso'), $class_name ), __FILE__, __FUNCTION__, __LINE__ );
162
+		if ( ! class_exists($class_name)) {
163
+			EE_Error::add_error(sprintf(__('The template pack represented by a class corresponding to "%s" does not exist.  Likely the autoloader for this class has the wrong path or the incoming reference is mispelled.  The default template pack  been used to generate the templates instead.', 'event_espresso'), $class_name), __FILE__, __FUNCTION__, __LINE__);
164 164
 			$class_name = 'EE_Messages_Template_Pack_Default';
165 165
 		}
166 166
 
167 167
 		$template_pack = new $class_name;
168 168
 
169 169
 		//get all the templates from the template pack.
170
-		$this->_templates = $template_pack->get_templates( $this->_messenger, $this->_message_type );
170
+		$this->_templates = $template_pack->get_templates($this->_messenger, $this->_message_type);
171 171
 	}
172 172
 
173 173
 
@@ -185,29 +185,29 @@  discard block
 block discarded – undo
185 185
 		$active_message_types = $this->_EE_MSG->get_installed_message_types();
186 186
 
187 187
 		//check if messenger is active
188
-		if ( !isset($active_messengers[$this->_m_name] ) ) {
188
+		if ( ! isset($active_messengers[$this->_m_name])) {
189 189
 			$msg[] = __('Message Templates cannot be generated because the given messenger is not active', 'event_espresso');
190
-			$msg[] = sprintf( __('The "$_m_name" property has "%s" as its value.  Check the spelling and make sure it matches an available messenger', 'event_espresso'), $this->_m_name );
191
-			throw new EE_Error( implode( '||', $msg ) );
190
+			$msg[] = sprintf(__('The "$_m_name" property has "%s" as its value.  Check the spelling and make sure it matches an available messenger', 'event_espresso'), $this->_m_name);
191
+			throw new EE_Error(implode('||', $msg));
192 192
 		}
193 193
 
194 194
 		//check if message type is installed
195
-		if ( !isset($active_messengers[$this->_m_name] ) ) {
195
+		if ( ! isset($active_messengers[$this->_m_name])) {
196 196
 			$msg[] = __('Message Templates cannot be generated because the given message type is not installed', 'event_espresso');
197
-			$msg[] = sprintf( __('The "$_mt_name" property has "%s" as its value.  Check the spelling and make sure it matches an available message type', 'event_espresso'), $this->_mt_name );
198
-			throw new EE_Error( implode( '||', $msg ) );
197
+			$msg[] = sprintf(__('The "$_mt_name" property has "%s" as its value.  Check the spelling and make sure it matches an available message type', 'event_espresso'), $this->_mt_name);
198
+			throw new EE_Error(implode('||', $msg));
199 199
 		}
200 200
 
201 201
 		$this->_messenger = $active_messengers[$this->_m_name];
202 202
 		$this->_message_type = $active_message_types[$this->_mt_name];
203 203
 
204 204
 		//verify we have the messenger and message type objects
205
-		if ( ! $this->_messenger instanceof EE_messenger ) {
206
-			throw new EE_Error( sprintf( __('The _messenger property must be an instance of EE_messenger by this point.  It isn\'t. Something has gone wrong. Here is the value it holds:<br /> %s', 'event_espresso' ), print_r( $this->_messenger, TRUE ) ) );
205
+		if ( ! $this->_messenger instanceof EE_messenger) {
206
+			throw new EE_Error(sprintf(__('The _messenger property must be an instance of EE_messenger by this point.  It isn\'t. Something has gone wrong. Here is the value it holds:<br /> %s', 'event_espresso'), print_r($this->_messenger, TRUE)));
207 207
 		}
208 208
 
209
-		if ( ! $this->_message_type instanceof EE_message_type ) {
210
-			throw new EE_Error( sprintf( __('The _message_type property must be an instance of EE_message_type by this point.  It isn\'t. Something has gone wrong. Here is the value it holds:<br /> %s', 'event_espresso' ), print_r( $this->_message_type, TRUE ) ) );
209
+		if ( ! $this->_message_type instanceof EE_message_type) {
210
+			throw new EE_Error(sprintf(__('The _message_type property must be an instance of EE_message_type by this point.  It isn\'t. Something has gone wrong. Here is the value it holds:<br /> %s', 'event_espresso'), print_r($this->_message_type, TRUE)));
211 211
 		}
212 212
 
213 213
 
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
 	public function create_new_templates() {
236 236
 		$template_pack = 'default';
237 237
 		//if we have the GRP_ID then let's use that to see if there is a set template pack and use that for the new templates.
238
-		if ( !empty( $this->_GRP_ID ) ) {
239
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $this->_GRP_ID );
238
+		if ( ! empty($this->_GRP_ID)) {
239
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_GRP_ID);
240 240
 			$template_pack = $mtpg instanceof EE_Message_Template_Group ? $mtpg->get_template_pack_name() : 'default';
241 241
 			//we also need to reset the template variation to default
242
-			$mtpg->set_template_pack_variation( 'default' );
242
+			$mtpg->set_template_pack_variation('default');
243 243
 		}
244
-		return $this->_create_new_templates( $template_pack );
244
+		return $this->_create_new_templates($template_pack);
245 245
 	}
246 246
 
247 247
 
@@ -254,15 +254,15 @@  discard block
 block discarded – undo
254 254
 	 * @param string $template_pack This corresponds to a template pack class reference which will contain information about where to obtain the templates.
255 255
 	 * @return mixed (array|bool)            success array or false.
256 256
 	 */
257
-	private function _create_new_templates( $template_pack ) {
257
+	private function _create_new_templates($template_pack) {
258 258
 
259
-		$this->_set_templates( $template_pack );
259
+		$this->_set_templates($template_pack);
260 260
 
261 261
 		//necessary properties are set, let's save the default templates
262 262
 
263
-		if ( empty( $this->_GRP_ID ) ) {
263
+		if (empty($this->_GRP_ID)) {
264 264
 
265
-			$main_template_data =  array(
265
+			$main_template_data = array(
266 266
 				'MTP_messenger' => $this->_messenger->name,
267 267
 				'MTP_message_type' => $this->_message_type->name,
268 268
 				'MTP_is_override' => 0,
@@ -274,24 +274,24 @@  discard block
 block discarded – undo
274 274
 
275 275
 
276 276
 			//let's insert the above and get our GRP_ID, then reset the template data array to just include the GRP_ID
277
-			$grp_id = $this->_EEM_data->insert( $main_template_data );
277
+			$grp_id = $this->_EEM_data->insert($main_template_data);
278 278
 
279
-			if ( empty( $grp_id ) ) return $grp_id;
279
+			if (empty($grp_id)) return $grp_id;
280 280
 			$this->_GRP_ID = $grp_id;
281 281
 		}
282 282
 
283
-		$template_data = array( 'GRP_ID' => $this->_GRP_ID );
283
+		$template_data = array('GRP_ID' => $this->_GRP_ID);
284 284
 
285
-		foreach ( $this->_contexts as $context => $details ) {
286
-			foreach ( $this->_fields as $field => $field_type ) {
287
-				if ( $field != 'extra' ) {
285
+		foreach ($this->_contexts as $context => $details) {
286
+			foreach ($this->_fields as $field => $field_type) {
287
+				if ($field != 'extra') {
288 288
 					$template_data['MTP_context'] = $context;
289 289
 					$template_data['MTP_template_field'] = $field;
290 290
 					$template_data['MTP_content'] = $this->_templates[$context][$field];
291 291
 
292 292
 					$MTP = EEM_Message_Template::instance()->insert($template_data);
293
-					if ( !$MTP ) {
294
-						EE_Error::add_error( sprintf(__('There was an error in saving new template data for %s messenger, %s message type, %s context and %s template field.', 'event_espresso'), $this->_messenger->name, $this->_message_type->name, $context, $field), __FILE__, __FUNCTION__, __LINE__  );
293
+					if ( ! $MTP) {
294
+						EE_Error::add_error(sprintf(__('There was an error in saving new template data for %s messenger, %s message type, %s context and %s template field.', 'event_espresso'), $this->_messenger->name, $this->_message_type->name, $context, $field), __FILE__, __FUNCTION__, __LINE__);
295 295
 						return false;
296 296
 					}
297 297
 				}
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
4 4
 	exit('NO direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
@@ -276,7 +277,9 @@  discard block
 block discarded – undo
276 277
 			//let's insert the above and get our GRP_ID, then reset the template data array to just include the GRP_ID
277 278
 			$grp_id = $this->_EEM_data->insert( $main_template_data );
278 279
 
279
-			if ( empty( $grp_id ) ) return $grp_id;
280
+			if ( empty( $grp_id ) ) {
281
+				return $grp_id;
282
+			}
280 283
 			$this->_GRP_ID = $grp_id;
281 284
 		}
282 285
 
Please login to merge, or discard this patch.
libraries/messages/defaults/EE_Messages_Template_Pack_Default.class.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 		$this->label = __('Default', 'event_espresso');
22 22
 		$this->dbref = 'default';
23 23
 		$this->description = __('This is the default template pack included with Event Espress core messages system.', 'event_espresso');
24
-		$this->_base_url = EE_PLUGIN_DIR_URL . 'core/libraries/messages/defaults/default/';
25
-		$this->_base_path = EE_LIBRARIES . 'messages/defaults/default/';
24
+		$this->_base_url = EE_PLUGIN_DIR_URL.'core/libraries/messages/defaults/default/';
25
+		$this->_base_path = EE_LIBRARIES.'messages/defaults/default/';
26 26
 		$this->_supports = array(
27 27
 			'email' => array(
28 28
 				'cancelled_registration', 'declined_registration', 'not_approved_registration', 'pending_approval', 'registration',
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 				'receipt', 'invoice'
34 34
 				)
35 35
 			);
36
-		$this->_default_variation_labels= array(
37
-			'email' => __('Default', 'event_espresso' ),
38
-			'html' =>  __('Simple', 'event_espresso' )
36
+		$this->_default_variation_labels = array(
37
+			'email' => __('Default', 'event_espresso'),
38
+			'html' =>  __('Simple', 'event_espresso')
39 39
 			 );
40 40
 		$this->_variations = array(
41 41
 			'html' => array(
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 
66
-	public function get_default_variation( $messenger, $message_type, $type, $url, $file_extension ) {
66
+	public function get_default_variation($messenger, $message_type, $type, $url, $file_extension) {
67 67
 		$base = $url ? $this->_base_url : $this->_base_path;
68 68
 		$base_path = $this->_base_path;
69 69
 		//possible variation paths considering whether message type is present or not in the file name.
70
-		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_default' . $file_extension;
71
-		$default_path_string = 'variations/' . $messenger . '_' . $type . '_default' . $file_extension;
70
+		$path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_default'.$file_extension;
71
+		$default_path_string = 'variations/'.$messenger.'_'.$type.'_default'.$file_extension;
72 72
 		//first see if fully validated file exists.
73
-		if ( is_readable( $base_path . $path_string ) ) {
74
-			$variation_path = $base . $path_string;
73
+		if (is_readable($base_path.$path_string)) {
74
+			$variation_path = $base.$path_string;
75 75
 		//otherwise see if default exists.
76
-		} elseif ( is_readable( $base_path . $default_path_string ) ) {
77
-			$variation_path = $base . $default_path_string;
76
+		} elseif (is_readable($base_path.$default_path_string)) {
77
+			$variation_path = $base.$default_path_string;
78 78
 		} else {
79 79
 			//no matches found so nothing is present.
80 80
 			$variation_path = '';
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage messages
6 6
  * @since           4.5.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * This is the default messages template pack.
Please login to merge, or discard this patch.
messages/defaults/default/email_cancelled_registration_content.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( __( 'Hello, %s', 'event_espresso' ), '[RECIPIENT_FNAME]' ); ?>:</h2>
34
+									<h2><?php printf(__('Hello, %s', 'event_espresso'), '[RECIPIENT_FNAME]'); ?>:</h2>
35 35
 
36
-									<p class="lead"><?php _e( 'Your registration was cancelled for the following tickets:', 'event_espresso' ); ?></p>
36
+									<p class="lead"><?php _e('Your registration was cancelled for the following tickets:', 'event_espresso'); ?></p>
37 37
 								</td>
38 38
 							</tr>
39 39
 						</tbody>
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 									<tbody>
63 63
 										<tr>
64 64
 											<td>
65
-												<h5><?php _e( 'Connect with Us:', 'event_espresso' ); ?></h5>
66
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e( 'Facebook', 'event_espresso' ); ?></a>
67
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e( 'Twitter', 'event_espresso' ); ?></a>
68
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e( 'Google+', 'event_espresso' ); ?></a>
65
+												<h5><?php _e('Connect with Us:', 'event_espresso'); ?></h5>
66
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e('Facebook', 'event_espresso'); ?></a>
67
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e('Twitter', 'event_espresso'); ?></a>
68
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e('Google+', 'event_espresso'); ?></a>
69 69
 											</td>
70 70
 										</tr>
71 71
 									</tbody>
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 									<tbody>
76 76
 										<tr>
77 77
 											<td>
78
-												<h5><?php _e( 'Contact Info:', 'event_espresso' ); ?></h5>
79
-												<?php _e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
80
-												<?php _e( 'Email:', 'event_espresso' ); ?>
78
+												<h5><?php _e('Contact Info:', 'event_espresso'); ?></h5>
79
+												<?php _e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
80
+												<?php _e('Email:', 'event_espresso'); ?>
81 81
 												<strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
82 82
 											</td>
83 83
 										</tr>
Please login to merge, or discard this patch.
defaults/default/email_cancelled_registration_content_admin.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( __( 'Hello, %s:', 'event_espresso' ), '[EVENT_AUTHOR_FNAME]' ); ?></h2>
34
+									<h2><?php printf(__('Hello, %s:', 'event_espresso'), '[EVENT_AUTHOR_FNAME]'); ?></h2>
35 35
 
36
-									<p class="lead"><?php _e( 'Registrations were cancelled for the following events.', 'event_espresso' ); ?></p>
36
+									<p class="lead"><?php _e('Registrations were cancelled for the following events.', 'event_espresso'); ?></p>
37 37
 								</td>
38 38
 							</tr>
39 39
 						</tbody>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 									<tbody>
60 60
 										<tr>
61 61
 											<td>
62
-												<h5><?php _e( 'Connect with Us:', 'event_espresso' ); ?></h5>
63
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e( 'Facebook', 'event_espresso' ); ?></a>
64
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e( 'Twitter', 'event_espresso' ); ?></a>
65
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e( 'Google+', 'event_espresso' ); ?></a>
62
+												<h5><?php _e('Connect with Us:', 'event_espresso'); ?></h5>
63
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e('Facebook', 'event_espresso'); ?></a>
64
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e('Twitter', 'event_espresso'); ?></a>
65
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e('Google+', 'event_espresso'); ?></a>
66 66
 											</td>
67 67
 										</tr>
68 68
 									</tbody>
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 									<tbody>
73 73
 										<tr>
74 74
 											<td>
75
-												<h5><?php _e( 'Contact Info:', 'event_espresso' ); ?></h5>
76
-												<?php _e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
77
-												<?php _e( 'Email:', 'event_espresso' ); ?>
75
+												<h5><?php _e('Contact Info:', 'event_espresso'); ?></h5>
76
+												<?php _e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
77
+												<?php _e('Email:', 'event_espresso'); ?>
78 78
 												<strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
79 79
 											</td>
80 80
 										</tr>
Please login to merge, or discard this patch.
messages/defaults/default/email_declined_registration_content.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( __( 'Hello, %s:', 'event_espresso' ), '[RECIPIENT_FNAME]' ); ?></h2>
35
-									<p class="lead"><?php _e( 'Your registration was declined for the following tickets:', 'event_espresso' ); ?></p>
34
+									<h2><?php printf(__('Hello, %s:', 'event_espresso'), '[RECIPIENT_FNAME]'); ?></h2>
35
+									<p class="lead"><?php _e('Your registration was declined for the following tickets:', 'event_espresso'); ?></p>
36 36
 								</td>
37 37
 							</tr>
38 38
 						</tbody>
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
 									<tbody>
62 62
 										<tr>
63 63
 											<td>
64
-												<h5><?php _e( 'Connect with Us:', 'event_espresso' ); ?></h5>
65
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e( 'Facebook', 'event_espresso' ); ?></a>
66
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e( 'Twitter', 'event_espresso' ); ?></a>
67
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e( 'Google+', 'event_espresso' ); ?></a>
64
+												<h5><?php _e('Connect with Us:', 'event_espresso'); ?></h5>
65
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e('Facebook', 'event_espresso'); ?></a>
66
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e('Twitter', 'event_espresso'); ?></a>
67
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e('Google+', 'event_espresso'); ?></a>
68 68
 											</td>
69 69
 										</tr>
70 70
 									</tbody>
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
 									<tbody>
75 75
 										<tr>
76 76
 											<td>
77
-												<h5><?php _e( 'Contact Info:', 'event_espresso' ); ?></h5>
78
-												<?php _e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
79
-												<?php _e( 'Email:', 'event_espresso' ); ?>
77
+												<h5><?php _e('Contact Info:', 'event_espresso'); ?></h5>
78
+												<?php _e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
79
+												<?php _e('Email:', 'event_espresso'); ?>
80 80
 												<strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
81 81
 											</td>
82 82
 										</tr>
Please login to merge, or discard this patch.
defaults/default/email_declined_registration_content_admin.template.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 						<tbody>
32 32
 							<tr>
33 33
 								<td>
34
-									<h2><?php printf( __( 'Hello, %s:', 'event_espresso' ), '[EVENT_AUTHOR_FNAME]' ); ?></h2>
35
-									<p class="lead"><?php _e( 'Registrations were declined for the following events:', 'event_espresso' ); ?></p>
34
+									<h2><?php printf(__('Hello, %s:', 'event_espresso'), '[EVENT_AUTHOR_FNAME]'); ?></h2>
35
+									<p class="lead"><?php _e('Registrations were declined for the following events:', 'event_espresso'); ?></p>
36 36
 								</td>
37 37
 							</tr>
38 38
 						</tbody>
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 									<tbody>
59 59
 										<tr>
60 60
 											<td>
61
-												<h5><?php _e( 'Connect with Us:', 'event_espresso' ); ?></h5>
62
-												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e( 'Facebook', 'event_espresso' ); ?></a>
63
-												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e( 'Twitter', 'event_espresso' ); ?></a>
64
-												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e( 'Google+', 'event_espresso' ); ?></a>
61
+												<h5><?php _e('Connect with Us:', 'event_espresso'); ?></h5>
62
+												<a class="soc-btn fb" href="[CO_FACEBOOK_URL]"><?php _e('Facebook', 'event_espresso'); ?></a>
63
+												<a class="soc-btn tw" href="[CO_TWITTER_URL]"><?php _e('Twitter', 'event_espresso'); ?></a>
64
+												<a class="soc-btn gp" href="[CO_GOOGLE_URL]"><?php _e('Google+', 'event_espresso'); ?></a>
65 65
 											</td>
66 66
 										</tr>
67 67
 									</tbody>
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 									<tbody>
72 72
 										<tr>
73 73
 											<td>
74
-												<h5><?php _e( 'Contact Info:', 'event_espresso' ); ?></h5>
75
-												<?php _e( 'Phone:', 'event_espresso' ); ?> <strong>[CO_PHONE]</strong>
76
-												<?php _e( 'Email:', 'event_espresso' ); ?>
74
+												<h5><?php _e('Contact Info:', 'event_espresso'); ?></h5>
75
+												<?php _e('Phone:', 'event_espresso'); ?> <strong>[CO_PHONE]</strong>
76
+												<?php _e('Email:', 'event_espresso'); ?>
77 77
 												<strong><a href="mailto:[CO_EMAIL]" target="_blank">[CO_EMAIL]</a></strong>
78 78
 											</td>
79 79
 										</tr>
Please login to merge, or discard this patch.
messages/defaults/default/email_declined_registration_subject.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,1 +1,1 @@
 block discarded – undo
1
-<?php _e('Declined Registration Details', 'event_espresso');?>
2 1
\ No newline at end of file
2
+<?php _e('Declined Registration Details', 'event_espresso'); ?>
3 3
\ No newline at end of file
Please login to merge, or discard this patch.