Completed
Branch old/BUG-7514-7935-7936-price-o... (518ae6)
by
unknown
11:51 queued 09:31
created
libraries/line_item_display/EE_SPCO_Line_Item_Display_Strategy.strategy.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_SPCO_Line_Item_Display_Strategy
5
- *
6
- * Description
7
- *
8
- * @package         Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- * @since		 	   $VID:$
12
- *
13
- */
3
+  *
4
+  * Class EE_SPCO_Line_Item_Display_Strategy
5
+  *
6
+  * Description
7
+  *
8
+  * @package         Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  * @since		 	   $VID:$
12
+  *
13
+  */
14 14
 
15 15
 class EE_SPCO_Line_Item_Display_Strategy implements EEI_Line_Item_Display {
16 16
 
Please login to merge, or discard this patch.
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -21,73 +21,73 @@  discard block
 block discarded – undo
21 21
 	 * @param array        $options
22 22
 	 * @return mixed
23 23
 	 */
24
-	public function display_line_item( EE_Line_Item $line_item, $options = array() ) {
24
+	public function display_line_item(EE_Line_Item $line_item, $options = array()) {
25 25
 
26
-		EE_Registry::instance()->load_helper( 'Template' );
27
-		EE_Registry::instance()->load_helper( 'HTML' );
26
+		EE_Registry::instance()->load_helper('Template');
27
+		EE_Registry::instance()->load_helper('HTML');
28 28
 
29 29
 		$html = '';
30 30
 		// set some default options and merge with incoming
31 31
 		$default_options = array(
32
-			'show_desc' => TRUE,  // 	TRUE 		FALSE
32
+			'show_desc' => TRUE, // 	TRUE 		FALSE
33 33
 			'odd' => FALSE
34 34
 		);
35
-		$options = array_merge( $default_options, (array)$options );
35
+		$options = array_merge($default_options, (array) $options);
36 36
 
37
-		switch( $line_item->type() ) {
37
+		switch ($line_item->type()) {
38 38
 
39 39
 			case EEM_Line_Item::type_line_item:
40 40
 				// item row
41
-				$html .= $this->_item_row( $line_item, $options );
41
+				$html .= $this->_item_row($line_item, $options);
42 42
 				// got any kids?
43
-				foreach( $line_item->children() as $child_line_item ) {
44
-					$this->display_line_item( $child_line_item, $options );
43
+				foreach ($line_item->children() as $child_line_item) {
44
+					$this->display_line_item($child_line_item, $options);
45 45
 				}
46 46
 				break;
47 47
 
48 48
 			case EEM_Line_Item::type_sub_line_item:
49
-				$html .= $this->_sub_item_row( $line_item, $options );
49
+				$html .= $this->_sub_item_row($line_item, $options);
50 50
 				break;
51 51
 
52 52
 			case EEM_Line_Item::type_sub_total:
53 53
 				static $sub_total = 0;
54 54
 				$child_line_items = $line_item->children();
55 55
 				// loop thru children
56
-				foreach( $child_line_items as $child_line_item ) {
56
+				foreach ($child_line_items as $child_line_item) {
57 57
 					// recursively feed children back into this method
58
-					$html .= $this->display_line_item( $child_line_item, $options );
58
+					$html .= $this->display_line_item($child_line_item, $options);
59 59
 				}
60
-				if ( $line_item->total() != $sub_total && count( $child_line_items ) > 1 ) {
61
-					$html .= $this->_sub_total_row( $line_item, __('Sub-Total', 'event_espresso'), $options );
60
+				if ($line_item->total() != $sub_total && count($child_line_items) > 1) {
61
+					$html .= $this->_sub_total_row($line_item, __('Sub-Total', 'event_espresso'), $options);
62 62
 					$sub_total = $line_item->total();
63 63
 				}
64 64
 				break;
65 65
 
66 66
 			case EEM_Line_Item::type_tax:
67
-				if ( $this->_show_taxes ) {
68
-					$html .= $this->_tax_row( $line_item, $options );
67
+				if ($this->_show_taxes) {
68
+					$html .= $this->_tax_row($line_item, $options);
69 69
 				}
70 70
 				break;
71 71
 
72 72
 			case EEM_Line_Item::type_tax_sub_total:
73
-				if ( $this->_show_taxes ) {
73
+				if ($this->_show_taxes) {
74 74
 					// loop thru children
75
-					foreach( $line_item->children() as $child_line_item ) {
75
+					foreach ($line_item->children() as $child_line_item) {
76 76
 						// recursively feed children back into this method
77
-						$html .= $this->display_line_item( $child_line_item, $options );
77
+						$html .= $this->display_line_item($child_line_item, $options);
78 78
 					}
79
-					$html .= $this->_total_row( $line_item, __('Tax Total', 'event_espresso'), $options );
79
+					$html .= $this->_total_row($line_item, __('Tax Total', 'event_espresso'), $options);
80 80
 				}
81 81
 				break;
82 82
 
83 83
 			case EEM_Line_Item::type_total:
84 84
 				// loop thru children
85
-				foreach( $line_item->children() as $child_line_item ) {
85
+				foreach ($line_item->children() as $child_line_item) {
86 86
 					// recursively feed children back into this method
87
-					$html .= $this->display_line_item( $child_line_item, $options );
87
+					$html .= $this->display_line_item($child_line_item, $options);
88 88
 				}
89
-				$html .= $this->_total_row( $line_item, __('Total', 'event_espresso'), $options );
90
-				$html .= $this->_payments_and_amount_owing_rows( $line_item );
89
+				$html .= $this->_total_row($line_item, __('Total', 'event_espresso'), $options);
90
+				$html .= $this->_payments_and_amount_owing_rows($line_item);
91 91
 				break;
92 92
 
93 93
 		}
@@ -104,10 +104,10 @@  discard block
 block discarded – undo
104 104
 	 * @param array        $options
105 105
 	 * @return mixed
106 106
 	 */
107
-	private function _item_row( EE_Line_Item $line_item, $options = array() ) {
107
+	private function _item_row(EE_Line_Item $line_item, $options = array()) {
108 108
 		// start of row
109 109
 		$row_class = $options['odd'] ? 'item odd' : 'item';
110
-		$html = EEH_HTML::tr( '', '', $row_class );
110
+		$html = EEH_HTML::tr('', '', $row_class);
111 111
 		// name && desc
112 112
 		$name_and_desc = apply_filters(
113 113
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__name',
@@ -116,21 +116,21 @@  discard block
 block discarded – undo
116 116
 		);
117 117
 		$name_and_desc .= apply_filters(
118 118
 			'FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc',
119
-			( $options['show_desc'] ? ' : ' . $line_item->desc() : '' ),
119
+			($options['show_desc'] ? ' : '.$line_item->desc() : ''),
120 120
 			$line_item,
121 121
 			$options
122 122
 		);
123 123
 		// name td
124
-		$html .= EEH_HTML::td( $name_and_desc, '',  'item_l' );
124
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l');
125 125
 		// quantity td
126
-		$html .= EEH_HTML::td( $line_item->quantity(), '',  'item_l jst-rght' );
126
+		$html .= EEH_HTML::td($line_item->quantity(), '', 'item_l jst-rght');
127 127
 		// price td
128
-		$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '',  'item_c jst-rght' );
128
+		$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
129 129
 		// total td
130
-		$total = EEH_Template::format_currency( $line_item->total(), false, false );
130
+		$total = EEH_Template::format_currency($line_item->total(), false, false);
131 131
 		$total .= $line_item->is_taxable() ? '*' : '';
132 132
 		$this->_show_taxes = $line_item->is_taxable() ? TRUE : $this->_show_taxes;
133
-		$html .= EEH_HTML::td( $total, '',  'item_r jst-rght' );
133
+		$html .= EEH_HTML::td($total, '', 'item_r jst-rght');
134 134
 		// end of row
135 135
 		$html .= EEH_HTML::trx();
136 136
 		return $html;
@@ -145,22 +145,22 @@  discard block
 block discarded – undo
145 145
 	 * @param array        $options
146 146
 	 * @return mixed
147 147
 	 */
148
-	private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) {
148
+	private function _sub_item_row(EE_Line_Item $line_item, $options = array()) {
149 149
 		// start of row
150
-		$html = EEH_HTML::tr( '', 'item sub-item-row' );
150
+		$html = EEH_HTML::tr('', 'item sub-item-row');
151 151
 		// name && desc
152 152
 		$name_and_desc = $line_item->name();
153
-		$name_and_desc .= $options['show_desc'] ? ' : ' . $line_item->desc() : '';
153
+		$name_and_desc .= $options['show_desc'] ? ' : '.$line_item->desc() : '';
154 154
 		// name td
155
-		$html .= EEH_HTML::td( $name_and_desc, '',  'item_l sub-item' );
155
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item');
156 156
 		// discount/surcharge td
157
-		if ( $line_item->is_percent() ) {
158
-			$html .= EEH_HTML::td( $line_item->percent() . '%', '',  'item_c' );
157
+		if ($line_item->is_percent()) {
158
+			$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c');
159 159
 		} else {
160
-			$html .= EEH_HTML::td( $line_item->unit_price_no_code(), '',  'item_c jst-rght' );
160
+			$html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'item_c jst-rght');
161 161
 		}
162 162
 		// total td
163
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
163
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
164 164
 		// end of row
165 165
 		$html .= EEH_HTML::trx();
166 166
 		return $html;
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
 	 * @param array        $options
176 176
 	 * @return mixed
177 177
 	 */
178
-	private function _tax_row( EE_Line_Item $line_item, $options = array() ) {
178
+	private function _tax_row(EE_Line_Item $line_item, $options = array()) {
179 179
 		// start of row
180
-		$html = EEH_HTML::tr( '', 'item sub-item tax-total' );
180
+		$html = EEH_HTML::tr('', 'item sub-item tax-total');
181 181
 		// name && desc
182 182
 		$name_and_desc = $line_item->name();
183
-		$name_and_desc .= $options['show_desc'] ? ' : ' . $line_item->desc() : '';
183
+		$name_and_desc .= $options['show_desc'] ? ' : '.$line_item->desc() : '';
184 184
 		// name td
185
-		$html .= EEH_HTML::td( $name_and_desc, '',  'item_l sub-item', '', ' colspan="2"' );
185
+		$html .= EEH_HTML::td($name_and_desc, '', 'item_l sub-item', '', ' colspan="2"');
186 186
 		// percent td
187
-		$html .= EEH_HTML::td( $line_item->percent() . '%', '',  'item_c', '' );
187
+		$html .= EEH_HTML::td($line_item->percent().'%', '', 'item_c', '');
188 188
 		// total td
189
-		$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'item_r jst-rght' );
189
+		$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'item_r jst-rght');
190 190
 		// end of row
191 191
 		$html .= EEH_HTML::trx();
192 192
 		return $html;
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 	 * @param array        $options
203 203
 	 * @return mixed
204 204
 	 */
205
-	private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) {
206
-		if ( $line_item->total() ) {
207
-			return $this->_total_row( $line_item, $text, $options);
205
+	private function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) {
206
+		if ($line_item->total()) {
207
+			return $this->_total_row($line_item, $text, $options);
208 208
 		}
209 209
 		return '';
210 210
 	}
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
 	 * @param array        $options
220 220
 	 * @return mixed
221 221
 	 */
222
-	private function _total_row( EE_Line_Item $line_item, $text = '', $options = array() ) {
222
+	private function _total_row(EE_Line_Item $line_item, $text = '', $options = array()) {
223 223
 		$html = '';
224
-		if ( $line_item->total() ) {
224
+		if ($line_item->total()) {
225 225
 			// start of row
226
-			$html = EEH_HTML::tr( '', '', 'total_tr odd' );
226
+			$html = EEH_HTML::tr('', '', 'total_tr odd');
227 227
 			// total td
228
-			$html .= EEH_HTML::td( $text, '',  'total_currency total jst-rght',  '',  ' colspan="3"' );
228
+			$html .= EEH_HTML::td($text, '', 'total_currency total jst-rght', '', ' colspan="3"');
229 229
 			// total td
230
-			$html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '',  'total jst-rght' );
230
+			$html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'total jst-rght');
231 231
 			// end of row
232 232
 			$html .= EEH_HTML::trx();
233 233
 		}
@@ -242,38 +242,38 @@  discard block
 block discarded – undo
242 242
 	 * @param EE_Line_Item $line_item
243 243
 	 * @return mixed
244 244
 	 */
245
-	private function _payments_and_amount_owing_rows( EE_Line_Item $line_item ) {
245
+	private function _payments_and_amount_owing_rows(EE_Line_Item $line_item) {
246 246
 		$html = '';
247
-		$transaction = EEM_Transaction::instance()->get_one_by_ID( $line_item->TXN_ID() );
248
-		if ( $transaction instanceof EE_Transaction ) {
247
+		$transaction = EEM_Transaction::instance()->get_one_by_ID($line_item->TXN_ID());
248
+		if ($transaction instanceof EE_Transaction) {
249 249
 			$payments = $transaction->approved_payments();
250
-			if ( ! empty( $payments )) {
250
+			if ( ! empty($payments)) {
251 251
 				$owing = $line_item->total();
252
-				foreach ( $payments as $payment ) {
253
-					if ( $payment instanceof EE_Payment ) {
252
+				foreach ($payments as $payment) {
253
+					if ($payment instanceof EE_Payment) {
254 254
 						$owing = $owing - $payment->amount();
255 255
 						$payment_desc = sprintf(
256 256
 							__('Payment%1$s Received: %2$s', 'event_espresso'),
257
-							$payment->txn_id_chq_nmbr() != '' ? ' ' . $payment->txn_id_chq_nmbr() : '',
257
+							$payment->txn_id_chq_nmbr() != '' ? ' '.$payment->txn_id_chq_nmbr() : '',
258 258
 							$payment->timestamp()
259 259
 						);
260 260
 						// start of row
261
-						$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
261
+						$html .= EEH_HTML::tr('', '', 'total_tr odd');
262 262
 						// payment desc
263
-						$html .= EEH_HTML::td( $payment_desc, '',  '',  '',  ' colspan="3"' );
263
+						$html .= EEH_HTML::td($payment_desc, '', '', '', ' colspan="3"');
264 264
 						// total td
265
-						$html .= EEH_HTML::td( EEH_Template::format_currency( $payment->amount(), false, false ), '',  'total jst-rght' );
265
+						$html .= EEH_HTML::td(EEH_Template::format_currency($payment->amount(), false, false), '', 'total jst-rght');
266 266
 						// end of row
267 267
 						$html .= EEH_HTML::trx();
268 268
 					}
269 269
 				}
270
-				if ( $line_item->total() ) {
270
+				if ($line_item->total()) {
271 271
 					// start of row
272
-					$html .= EEH_HTML::tr( '', '', 'total_tr odd' );
272
+					$html .= EEH_HTML::tr('', '', 'total_tr odd');
273 273
 					// total td
274
-					$html .= EEH_HTML::td( __('Amount Owing', 'event_espresso'), '',  'total_currency total jst-rght',  '',  ' colspan="3"' );
274
+					$html .= EEH_HTML::td(__('Amount Owing', 'event_espresso'), '', 'total_currency total jst-rght', '', ' colspan="3"');
275 275
 					// total td
276
-					$html .= EEH_HTML::td( EEH_Template::format_currency( $owing, false, false ), '',  'total jst-rght' );
276
+					$html .= EEH_HTML::td(EEH_Template::format_currency($owing, false, false), '', 'total jst-rght');
277 277
 					// end of row
278 278
 					$html .= EEH_HTML::trx();
279 279
 				}
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
 	 * @param array        $options
291 291
 	 * @return mixed
292 292
 	 */
293
-	private function _separator_row( $options = array() ) {
293
+	private function _separator_row($options = array()) {
294 294
 		// start of row
295
-		$html = EEH_HTML::tr( EEH_HTML::td( '<hr>', '',  '',  '',  ' colspan="4"' ));
295
+		$html = EEH_HTML::tr(EEH_HTML::td('<hr>', '', '', '', ' colspan="4"'));
296 296
 		return $html;
297 297
 	}
298 298
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Base.lib.php 2 patches
Spacing   +14 added lines, -14 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
 /**
@@ -185,14 +185,14 @@  discard block
 block discarded – undo
185 185
 	 * @access protected
186 186
 	 * @return void
187 187
 	 */
188
-	protected function _set_existing_admin_settings( $messenger = NULL ) {
188
+	protected function _set_existing_admin_settings($messenger = NULL) {
189 189
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
190
-		$active_message_types = !empty( $messenger ) ? $active_messengers[$messenger]['settings'][$messenger . '-message_types'] : array();
190
+		$active_message_types = ! empty($messenger) ? $active_messengers[$messenger]['settings'][$messenger.'-message_types'] : array();
191 191
 
192 192
 
193 193
 		$actives = $this->_messages_item_type == 'messenger' ? $active_messengers : $active_message_types;
194 194
 
195
-		$this->_existing_admin_settings = isset($actives[$this->name]['settings'] ) ? $actives[$this->name]['settings'] : null;
195
+		$this->_existing_admin_settings = isset($actives[$this->name]['settings']) ? $actives[$this->name]['settings'] : null;
196 196
 	}
197 197
 
198 198
 
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 	 * @access public
208 208
 	 * @return array          settings
209 209
 	 */
210
-	public function get_existing_admin_settings( $messenger = NULL ) {
210
+	public function get_existing_admin_settings($messenger = NULL) {
211 211
 		// if admin_settings property empty lets try setting it.
212
-		if ( method_exists($this, '_set_existing_admin_settings') && empty( $this->_existing_admin_settings ) )
213
-			$this->_set_existing_admin_settings( $messenger );
212
+		if (method_exists($this, '_set_existing_admin_settings') && empty($this->_existing_admin_settings))
213
+			$this->_set_existing_admin_settings($messenger);
214 214
 
215 215
 		return EEH_Class_Tools::has_property($this, '_existing_admin_settings') ? $this->_existing_admin_settings : null;
216 216
 	}
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 	 * @return array   an array of valid shortcodes.
226 226
 	 */
227 227
 	public function get_valid_shortcodes() {
228
-		$valid_shortcodes = apply_filters( 'FHEE__' . get_class($this) . '__get_valid_shortcodes', $this->_valid_shortcodes, $this );
228
+		$valid_shortcodes = apply_filters('FHEE__'.get_class($this).'__get_valid_shortcodes', $this->_valid_shortcodes, $this);
229 229
 
230 230
 		//The below filter applies to ALL messengers and message types so use with care!
231
-		$valid_shortcodes = apply_filters( 'FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this );
231
+		$valid_shortcodes = apply_filters('FHEE__EE_Messages_Base__get_valid_shortcodes', $valid_shortcodes, $this);
232 232
 		return $valid_shortcodes;
233 233
 	}
234 234
 
@@ -259,17 +259,17 @@  discard block
 block discarded – undo
259 259
 	 * @access protected
260 260
 	 * @return string $content for page.
261 261
 	 */
262
-	protected function _get_admin_page_content( $page, $action, $extra, $actives ) {
262
+	protected function _get_admin_page_content($page, $action, $extra, $actives) {
263 263
 		//we can also further refine the context by action (if present).
264
-		if ( !empty($action) ) {
265
-			$page = $page . '_' . $action;
264
+		if ( ! empty($action)) {
265
+			$page = $page.'_'.$action;
266 266
 		}
267 267
 
268
-		if ( !isset( $this->admin_registered_pages[$page]) )
268
+		if ( ! isset($this->admin_registered_pages[$page]))
269 269
 			return false; //todo: a place to throw an exception?  We need to indicate there is no registered page so this function is not being called correctly.
270 270
 
271 271
 		//k made it here so let's call the method
272
-		if ( FALSE === ( $content = call_user_func_array( array( $this, '_get_admin_content_' . $page), array($actives, $extra) ) ) ) {
272
+		if (FALSE === ($content = call_user_func_array(array($this, '_get_admin_content_'.$page), array($actives, $extra)))) {
273 273
 			return false; //todo this needs to be an exception once we've got exceptions in place.
274 274
 		}
275 275
 		return $content;
Please login to merge, or discard this patch.
Braces   +9 added lines, -5 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
@@ -209,8 +210,9 @@  discard block
 block discarded – undo
209 210
 	 */
210 211
 	public function get_existing_admin_settings( $messenger = NULL ) {
211 212
 		// if admin_settings property empty lets try setting it.
212
-		if ( method_exists($this, '_set_existing_admin_settings') && empty( $this->_existing_admin_settings ) )
213
-			$this->_set_existing_admin_settings( $messenger );
213
+		if ( method_exists($this, '_set_existing_admin_settings') && empty( $this->_existing_admin_settings ) ) {
214
+					$this->_set_existing_admin_settings( $messenger );
215
+		}
214 216
 
215 217
 		return EEH_Class_Tools::has_property($this, '_existing_admin_settings') ? $this->_existing_admin_settings : null;
216 218
 	}
@@ -265,8 +267,10 @@  discard block
 block discarded – undo
265 267
 			$page = $page . '_' . $action;
266 268
 		}
267 269
 
268
-		if ( !isset( $this->admin_registered_pages[$page]) )
269
-			return false; //todo: a place to throw an exception?  We need to indicate there is no registered page so this function is not being called correctly.
270
+		if ( !isset( $this->admin_registered_pages[$page]) ) {
271
+					return false;
272
+		}
273
+		//todo: a place to throw an exception?  We need to indicate there is no registered page so this function is not being called correctly.
270 274
 
271 275
 		//k made it here so let's call the method
272 276
 		if ( FALSE === ( $content = call_user_func_array( array( $this, '_get_admin_content_' . $page), array($actives, $extra) ) ) ) {
Please login to merge, or discard this patch.
core/libraries/messages/EE_Payment_Base_message_type.lib.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -39,31 +39,31 @@  discard block
 block discarded – undo
39 39
 
40 40
 
41 41
 
42
-	protected function _get_data_for_context( $context, EE_Registration $registration, $id ) {
42
+	protected function _get_data_for_context($context, EE_Registration $registration, $id) {
43 43
 
44 44
 		//use the registration to get the transaction.
45 45
 		$transaction = $registration->transaction();
46 46
 
47 47
 		//bail early if no transaction
48
-		if ( ! $transaction instanceof EE_Transaction ) {
49
-			throw new EE_Error( __('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso' ) );
48
+		if ( ! $transaction instanceof EE_Transaction) {
49
+			throw new EE_Error(__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
50 50
 		}
51 51
 
52
-		$payment = ! empty( $id ) ? EEM_Payment::instance()->get_one( array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) ) ) : 0;
52
+		$payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0;
53 53
 
54
-		return array( $transaction, $payment );
54
+		return array($transaction, $payment);
55 55
 	}
56 56
 
57 57
 
58 58
 
59 59
 
60 60
 
61
-	protected function _get_id_for_msg_url( $context, EE_Registration $registration ) {
61
+	protected function _get_id_for_msg_url($context, EE_Registration $registration) {
62 62
 		//there should be a transaction and payment object in the incoming data.
63
-		if ( $this->_data instanceof EE_Messages_incoming_data  ) {
64
-			$payment = !empty( $this->_data->payment ) ? $this->_data->payment : NULL;
63
+		if ($this->_data instanceof EE_Messages_incoming_data) {
64
+			$payment = ! empty($this->_data->payment) ? $this->_data->payment : NULL;
65 65
 
66
-			if ( $payment instanceof EE_Payment ) {
66
+			if ($payment instanceof EE_Payment) {
67 67
 				return $payment->ID();
68 68
 			}
69 69
 		}
@@ -72,9 +72,9 @@  discard block
 block discarded – undo
72 72
 
73 73
 
74 74
 
75
-	protected function _get_admin_content_events_edit_for_messenger( EE_Messenger $messenger ) {
75
+	protected function _get_admin_content_events_edit_for_messenger(EE_Messenger $messenger) {
76 76
 		//this is just a test
77
-		return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
77
+		return $this->name.' Message Type for '.$messenger->name.' Messenger ';
78 78
 	}
79 79
 
80 80
 	/**
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@
 block discarded – undo
6 6
  * @subpackage messages
7 7
  * @since           4.5.0
8 8
  */
9
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11
+}
10 12
 
11 13
 /**
12 14
  * This class contains common methods/properties shared among all payment message types.
Please login to merge, or discard this patch.
core/libraries/messages/EE_Registration_Base_message_type.lib.php 2 patches
Braces   +9 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,7 +6,9 @@  discard block
 block discarded – undo
6 6
  * @subpackage messages
7 7
  * @since           4.5.0
8 8
  */
9
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11
+}
10 12
 
11 13
 /**
12 14
  * This class contains common methods/properties shared among all registration message types.
@@ -125,16 +127,18 @@  discard block
 block discarded – undo
125 127
 	 * @return array array of EE_Messages_Addressee objects
126 128
 	 */
127 129
 	protected function _admin_addressees() {
128
-		if ( $this->_single_message )
129
-			return array();
130
+		if ( $this->_single_message ) {
131
+					return array();
132
+		}
130 133
 		return parent::_admin_addressees();
131 134
 	}
132 135
 
133 136
 
134 137
 
135 138
 	protected function _primary_attendee_addressees() {
136
-		if ( $this->_single_message )
137
-			return array();
139
+		if ( $this->_single_message ) {
140
+					return array();
141
+		}
138 142
 
139 143
 		return parent::_primary_attendee_addressees();
140 144
 	}
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	}
30 30
 
31 31
 
32
-	protected function _get_admin_content_events_edit_for_messenger( EE_Messenger $messenger ) {
32
+	protected function _get_admin_content_events_edit_for_messenger(EE_Messenger $messenger) {
33 33
 		//this is just a test
34
-		return $this->name . ' Message Type for ' . $messenger->name . ' Messenger ';
34
+		return $this->name.' Message Type for '.$messenger->name.' Messenger ';
35 35
 	}
36 36
 
37 37
 
@@ -44,18 +44,18 @@  discard block
 block discarded – undo
44 44
 
45 45
 
46 46
 
47
-	protected function _get_data_for_context( $context, EE_Registration $registration, $id ) {
48
-		if ( $context  == 'admin' ) {
47
+	protected function _get_data_for_context($context, EE_Registration $registration, $id) {
48
+		if ($context == 'admin') {
49 49
 			//use the registration to get the transaction.
50 50
 			$transaction = $registration->transaction();
51 51
 
52 52
 			//bail early if no transaction
53
-			if ( ! $transaction instanceof EE_Transaction ) {
54
-				throw new EE_Error( __('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso' ) );
53
+			if ( ! $transaction instanceof EE_Transaction) {
54
+				throw new EE_Error(__('The given registration does not have an associated transaction. Something is wrong.', 'event_espresso'));
55 55
 			}
56 56
 
57
-			$payment = !empty( $id ) ? EEM_Payment::instance()->get_one( array( array( 'PAY_ID' => $id, 'TXN_ID' => $transaction->ID() ) ) ) : 0;
58
-			return array( $transaction, $payment );
57
+			$payment = ! empty($id) ? EEM_Payment::instance()->get_one(array(array('PAY_ID' => $id, 'TXN_ID' => $transaction->ID()))) : 0;
58
+			return array($transaction, $payment);
59 59
 		} else {
60 60
 			return $registration;
61 61
 		}
@@ -63,13 +63,13 @@  discard block
 block discarded – undo
63 63
 
64 64
 
65 65
 
66
-	protected function _get_id_for_msg_url( $context, EE_Registration $registration ) {
67
-		if ( $context == 'admin' ) {
66
+	protected function _get_id_for_msg_url($context, EE_Registration $registration) {
67
+		if ($context == 'admin') {
68 68
 			//there should be a transaction and payment object in the incoming data.
69
-			if ( $this->_data instanceof EE_Messages_incoming_data && ! $this->_data instanceof EE_Messages_Preview_incoming_data ) {
69
+			if ($this->_data instanceof EE_Messages_incoming_data && ! $this->_data instanceof EE_Messages_Preview_incoming_data) {
70 70
 				$payment = $this->_data->payment;
71 71
 
72
-				if ( $payment instanceof EE_Payment ) {
72
+				if ($payment instanceof EE_Payment) {
73 73
 					return $payment->ID();
74 74
 				}
75 75
 			}
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return array array of EE_Messages_Addressee objects
98 98
 	 */
99 99
 	protected function _admin_addressees() {
100
-		if ( $this->_single_message )
100
+		if ($this->_single_message)
101 101
 			return array();
102 102
 		return parent::_admin_addressees();
103 103
 	}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 
107 107
 	protected function _primary_attendee_addressees() {
108
-		if ( $this->_single_message )
108
+		if ($this->_single_message)
109 109
 			return array();
110 110
 
111 111
 		return parent::_primary_attendee_addressees();
Please login to merge, or discard this patch.
core/libraries/messages/EE_message_type.lib.php 3 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.
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/EE_messages.lib.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -302,7 +302,7 @@
 block discarded – undo
302 302
 	 * @param  string $sending_messenger if included then we ONLY use the specified messenger for delivery.  Otherwise we cycle through all active messengers.
303 303
 	 * @param string $generating_messenger if included then this messenger is used for generating the message templates (but not for sending).
304 304
 	 * @param string $context If included then only a message type for a specific context will be generated.
305
-	  * @param bool  $send 			       Default TRUE.  If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it).
305
+	 * @param bool  $send 			       Default TRUE.  If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it).
306 306
 	 * @return bool
307 307
 	 */
308 308
 	public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) {
Please login to merge, or discard this patch.
Braces   +27 added lines, -16 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
@@ -90,7 +91,7 @@  discard block
 block discarded – undo
90 91
 		if( ! isset( $active_messengers[ $messenger_name ] ) ) {
91 92
 			$this->activate_messenger( $messenger_name );
92 93
 			return FALSE;
93
-		}else{
94
+		} else{
94 95
 			return TRUE;
95 96
 		}
96 97
 	}
@@ -207,7 +208,9 @@  discard block
 block discarded – undo
207 208
 	private function _load_files($kind, $actives) {
208 209
 		$active_names = array();
209 210
 		$base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS;
210
-		if ( empty($actives) ) return false;
211
+		if ( empty($actives) ) {
212
+			return false;
213
+		}
211 214
 
212 215
 		//make sure autoloaders are set (failsafe)
213 216
 		EED_Messages::set_autoloaders();
@@ -418,8 +421,9 @@  discard block
 block discarded – undo
418 421
 			if ( isset( $this->_active_messengers[$messenger] ) ) {
419 422
 
420 423
 				//we ONLY continue if the given messenger has that message type active with it (note previews only come from primary messengers so no need to check secondarys)
421
-				if ( !isset( $this->_active_message_types[$messenger][$type] ) )
422
-					return false;
424
+				if ( !isset( $this->_active_message_types[$messenger][$type] ) ) {
425
+									return false;
426
+				}
423 427
 
424 428
 				$message = $installed_message_types[$type];
425 429
 				$messenger = $this->_active_messengers[$messenger];
@@ -553,8 +557,9 @@  discard block
 block discarded – undo
553 557
 
554 558
 
555 559
 		//do we have the necessary objects loaded?
556
-		if ( empty( $this->_messenger) || empty($this->_message_type) )
557
-			throw new EE_Error( sprintf( __(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type ) );
560
+		if ( empty( $this->_messenger) || empty($this->_message_type) ) {
561
+					throw new EE_Error( sprintf( __(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type ) );
562
+		}
558 563
 
559 564
 		//is given message_type valid for given messenger (if this is not a global save)
560 565
 		$types_to_check = array();
@@ -597,8 +602,9 @@  discard block
 block discarded – undo
597 602
 	protected function _create_new_templates($GRP_ID, $is_global) {
598 603
 
599 604
 		//if we're creating a custom template then we don't need to use the defaults class
600
-		if ( ! $is_global )
601
-			return $this->_create_custom_template_group( $GRP_ID );
605
+		if ( ! $is_global ) {
606
+					return $this->_create_custom_template_group( $GRP_ID );
607
+		}
602 608
 
603 609
 		$DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID );
604 610
 
@@ -663,14 +669,16 @@  discard block
 block discarded – undo
663 669
 
664 670
 		//add new message templates and add relation to.
665 671
 		foreach ( $mtts as $mtt ) {
666
-			if ( ! $mtt instanceof EE_Message_Template )
667
-				continue;
672
+			if ( ! $mtt instanceof EE_Message_Template ) {
673
+							continue;
674
+			}
668 675
 			$nmtt = clone $mtt;
669 676
 			$nmtt->set('MTP_ID', 0);
670 677
 			$nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation
671 678
 			$nmtt->save();
672
-			if ( empty( $success['MTP_context'] ) )
673
-				$success['MTP_context'] = $nmtt->get('MTP_context');
679
+			if ( empty( $success['MTP_context'] ) ) {
680
+							$success['MTP_context'] = $nmtt->get('MTP_context');
681
+			}
674 682
 		}
675 683
 
676 684
 		return $success;
@@ -761,7 +769,9 @@  discard block
 block discarded – undo
761 769
 			$classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false;
762 770
 
763 771
 			//no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE.
764
-			if ( !$classname || 0 !== stripos($classname, 'EE') ) continue;
772
+			if ( !$classname || 0 !== stripos($classname, 'EE') ) {
773
+				continue;
774
+			}
765 775
 
766 776
 			//note: I'm not sure if this will work without including the file.  We do have autoloaders so it "may" work.
767 777
 			$a = new ReflectionClass($classname);
@@ -786,8 +796,9 @@  discard block
 block discarded – undo
786 796
 		$message_types = array();
787 797
 		foreach ( $this->_active_message_types as $messenger => $mtvalues ) {
788 798
 			foreach ( $mtvalues as $mt => $config ) {
789
-				if ( !in_array( $mt, $message_types ) )
790
-					$message_types[] = $mt;
799
+				if ( !in_array( $mt, $message_types ) ) {
800
+									$message_types[] = $mt;
801
+				}
791 802
 			}
792 803
 		}
793 804
 
Please login to merge, or discard this patch.
Spacing   +163 added lines, -163 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
 /**
@@ -63,17 +63,17 @@  discard block
 block discarded – undo
63 63
 		$actives = is_array($_actives) ? array_keys($_actives) : $_actives;
64 64
 		$active_names = $this->_load_files('messenger', $actives);
65 65
 
66
-		if ( is_array($active_names) ) {
67
-			foreach ( $active_names as $name => $class ) {
68
-				$a = new ReflectionClass( $class );
66
+		if (is_array($active_names)) {
67
+			foreach ($active_names as $name => $class) {
68
+				$a = new ReflectionClass($class);
69 69
 				$active = $a->newInstance();
70
-				if ( is_wp_error($active) ) {
70
+				if (is_wp_error($active)) {
71 71
 					//we've got an error so let's bubble up the error_object to be caught by caller.
72 72
 					//todo: would be better to just catch the errors and then return any aggregated errors later.
73 73
 					EE_Error::add_error($active->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
74 74
 				}
75 75
 				$this->_active_messengers[$name] = $active;
76
-				$this->_active_message_types[$name] = ! empty( $_actives[$name]['settings'][$name . '-message_types'] ) ? $_actives[$name]['settings'][$name . '-message_types'] : array();
76
+				$this->_active_message_types[$name] = ! empty($_actives[$name]['settings'][$name.'-message_types']) ? $_actives[$name]['settings'][$name.'-message_types'] : array();
77 77
 			}
78 78
 		}
79 79
 	}
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
 	 * @param string $messenger_name
85 85
 	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
86 86
 	 */
87
-	public function ensure_messenger_is_active( $messenger_name ){
87
+	public function ensure_messenger_is_active($messenger_name) {
88 88
 		//note: active messengers indexed by their names
89 89
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
90
-		if( ! isset( $active_messengers[ $messenger_name ] ) ) {
91
-			$this->activate_messenger( $messenger_name );
90
+		if ( ! isset($active_messengers[$messenger_name])) {
91
+			$this->activate_messenger($messenger_name);
92 92
 			return FALSE;
93
-		}else{
93
+		} else {
94 94
 			return TRUE;
95 95
 		}
96 96
 	}
@@ -105,21 +105,21 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return boolean true if it got activated (or was active) and false if not.
107 107
 	 */
108
-	public function ensure_message_type_is_active( $message_type, $messenger ) {
108
+	public function ensure_message_type_is_active($message_type, $messenger) {
109 109
 		//first validate that the incoming messenger allows this message type to be activated.
110 110
 		$messengers = $this->get_installed_messengers();
111
-		if ( ! isset( $messengers[$messenger] ) ) {
112
-			throw new EE_Error( sprintf( __('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__ ) );
111
+		if ( ! isset($messengers[$messenger])) {
112
+			throw new EE_Error(sprintf(__('The messenger sent to %s is not installed', 'event_espresso'), __METHOD__));
113 113
 		}
114 114
 
115 115
 		$msgr = $messengers[$messenger];
116 116
 		$valid_message_types = $msgr->get_valid_message_types();
117
-		if ( ! in_array( $message_type, $valid_message_types ) ) {
118
-			throw new EE_Error( sprint_f( __('The message type ($1%s) sent to $2%s is not valid for the $3%s messenger.  Doublecheck the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso' ), $message_type, __METHOD__, $messenger ) );
117
+		if ( ! in_array($message_type, $valid_message_types)) {
118
+			throw new EE_Error(sprint_f(__('The message type ($1%s) sent to $2%s is not valid for the $3%s messenger.  Doublecheck the spelling and verify that message type has been registered as a valid type with the messenger.', 'event_espresso'), $message_type, __METHOD__, $messenger));
119 119
 		}
120 120
 
121 121
 		//all is good so let's just get it active
122
-		return $this->activate_messenger( $messenger, array( $message_type ) );
122
+		return $this->activate_messenger($messenger, array($message_type));
123 123
 	}
124 124
 
125 125
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 *                             				they are already setup.)
131 131
 	 * @return boolean an array of generated templates or false if nothing generated/activated.
132 132
 	 */
133
-	public function activate_messenger( $messenger_name, $mts = array() ){
133
+	public function activate_messenger($messenger_name, $mts = array()) {
134 134
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
135 135
 		$message_types = $this->get_installed_message_types();
136 136
 		$installed_messengers = $this->get_installed_messengers();
@@ -138,33 +138,33 @@  discard block
 block discarded – undo
138 138
 		$templates = false;
139 139
 
140 140
 		//get has_active so we can be sure its kept up to date.
141
-		$has_activated = get_option( 'ee_has_activated_messenger' );
141
+		$has_activated = get_option('ee_has_activated_messenger');
142 142
 
143 143
 		//grab the messenger to work with.
144
-		$messenger = isset( $installed_messengers[$messenger_name] ) ? $installed_messengers[$messenger_name] : null;
144
+		$messenger = isset($installed_messengers[$messenger_name]) ? $installed_messengers[$messenger_name] : null;
145 145
 
146 146
 		//it's inactive. Activate it.
147 147
 
148
-		if( $messenger instanceof EE_messenger ) {
149
-			$active_messengers[ $messenger->name ][ 'obj' ] = $messenger;
148
+		if ($messenger instanceof EE_messenger) {
149
+			$active_messengers[$messenger->name]['obj'] = $messenger;
150 150
 
151 151
 			/** @var EE_messenger[] $installed_messengers  */
152
-			$mts_to_activate = ! empty( $mts ) ? $mts :  $messenger->get_default_message_types();
153
-			foreach ( $mts_to_activate as $message_type ) {
152
+			$mts_to_activate = ! empty($mts) ? $mts : $messenger->get_default_message_types();
153
+			foreach ($mts_to_activate as $message_type) {
154 154
 				//we need to setup any initial settings for message types
155 155
 				/** @var EE_message_type[] $installed_mts */
156
-				$settings_fields = isset( $message_types[$message_type] ) ? $message_types[ $message_type ]->get_admin_settings_fields() : array();
157
-				if ( !empty( $settings_fields ) ) {
158
-					foreach ( $settings_fields as $field => $values ) {
159
-						$settings[$field] = $values[ 'default' ];
156
+				$settings_fields = isset($message_types[$message_type]) ? $message_types[$message_type]->get_admin_settings_fields() : array();
157
+				if ( ! empty($settings_fields)) {
158
+					foreach ($settings_fields as $field => $values) {
159
+						$settings[$field] = $values['default'];
160 160
 					}
161 161
 				} else {
162 162
 					$settings = array();
163 163
 				}
164 164
 
165
-				$active_messengers[ $messenger->name ][ 'settings' ][ $messenger->name . '-message_types' ][ $message_type ][ 'settings' ] = $settings;
165
+				$active_messengers[$messenger->name]['settings'][$messenger->name.'-message_types'][$message_type]['settings'] = $settings;
166 166
 
167
-				if (  ! empty( $has_activated[$messenger->name] ) && ! in_array( $message_type, $has_activated[$messenger->name] ) ) {
167
+				if ( ! empty($has_activated[$messenger->name]) && ! in_array($message_type, $has_activated[$messenger->name])) {
168 168
 					$has_activated[$messenger->name][] = $message_type;
169 169
 				}
170 170
 			}
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
 			//setup any initial settings for the messenger
173 173
 			$msgr_settings = $messenger->get_admin_settings_fields();
174 174
 
175
-			if ( !empty( $msgr_settings ) ) {
176
-				foreach ( $msgr_settings as $field => $value ) {
177
-					$active_messengers[ $messenger->name ][ 'settings' ][ $field ] = $value;
175
+			if ( ! empty($msgr_settings)) {
176
+				foreach ($msgr_settings as $field => $value) {
177
+					$active_messengers[$messenger->name]['settings'][$field] = $value;
178 178
 				}
179 179
 			}
180 180
 
181
-			EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
182
-			update_option( 'ee_has_activated_messenger', $has_activated );
181
+			EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
182
+			update_option('ee_has_activated_messenger', $has_activated);
183 183
 
184 184
 			//make sure that the cached active_messengers is set on this object
185 185
 			$this->_active_messengers[$messenger->name] = $messenger;
186 186
 			$this->_active_message_types[$messenger->name] = $active_messengers[$messenger->name];
187 187
 
188 188
 			//might need to generate new templates
189
-			if ( ! empty( $mts_to_activate ) ) {
190
-				$templates = EEH_MSG_Template::generate_new_templates( $messenger->name, $mts_to_activate, 0, TRUE );
189
+			if ( ! empty($mts_to_activate)) {
190
+				$templates = EEH_MSG_Template::generate_new_templates($messenger->name, $mts_to_activate, 0, TRUE);
191 191
 			}
192 192
 		}
193 193
 
@@ -206,8 +206,8 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	private function _load_files($kind, $actives) {
208 208
 		$active_names = array();
209
-		$base_path = EE_LIBRARIES . 'messages' . DS . $kind . DS;
210
-		if ( empty($actives) ) return false;
209
+		$base_path = EE_LIBRARIES.'messages'.DS.$kind.DS;
210
+		if (empty($actives)) return false;
211 211
 
212 212
 		//make sure autoloaders are set (failsafe)
213 213
 		EED_Messages::set_autoloaders();
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
 		//make sure $actives is an array
216 216
 		$actives = (array) $actives;
217 217
 
218
-		EE_Registry::instance()->load_helper( 'File' );
219
-		foreach ( $actives as $active ) {
220
-			$msg_name = 'EE_' . ucwords( str_replace( ' ', '_', $active) ) . '_' . $kind;
221
-			$filename = $msg_name . '.class.php';
222
-			$load_file = $base_path . DS . $filename;
223
-			if ( is_readable($load_file) ) {
218
+		EE_Registry::instance()->load_helper('File');
219
+		foreach ($actives as $active) {
220
+			$msg_name = 'EE_'.ucwords(str_replace(' ', '_', $active)).'_'.$kind;
221
+			$filename = $msg_name.'.class.php';
222
+			$load_file = $base_path.DS.$filename;
223
+			if (is_readable($load_file)) {
224 224
 				require_once($load_file);
225 225
 				$active_names[$active] = $msg_name;
226 226
 			} else {
227 227
 				$this->_unset_active($active, $kind);
228 228
 				//set WP_Error
229
-				return EE_Error::add_error( sprintf( __("Missing messages system file set as inactive: (%s) %s has been made inactive.", 'event_espresso'), $load_file, $msg_name), __FILE__, __FUNCTION__, __LINE__ );
229
+				return EE_Error::add_error(sprintf(__("Missing messages system file set as inactive: (%s) %s has been made inactive.", 'event_espresso'), $load_file, $msg_name), __FILE__, __FUNCTION__, __LINE__);
230 230
 			}
231 231
 		}
232 232
 		return $active_names;
@@ -243,25 +243,25 @@  discard block
 block discarded – undo
243 243
 	 * @param  string $kind        messenger or message_type?
244 244
 	 * @return void
245 245
 	 */
246
-	private function _unset_active( $active_name, $kind ) {
246
+	private function _unset_active($active_name, $kind) {
247 247
 		//pluralize
248 248
 		$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
249
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
250
-		if ( $kind == 'messenger' ) {
251
-			unset( $active_messengers[$active_name] );
252
-			EEH_MSG_Template::update_to_inactive( $active_name );
253
-			if ( isset( $this->_active_messengers[$active_name] ) ) {
254
-				unset( $this->_active_messengers[$active_name] );
249
+		EE_Registry::instance()->load_helper('MSG_Template');
250
+		if ($kind == 'messenger') {
251
+			unset($active_messengers[$active_name]);
252
+			EEH_MSG_Template::update_to_inactive($active_name);
253
+			if (isset($this->_active_messengers[$active_name])) {
254
+				unset($this->_active_messengers[$active_name]);
255 255
 			}
256 256
 		} else {
257
-			foreach( $active_messengers as $messenger => $settings ) {
258
-				if ( ! empty( $settings['settings'][$messenger . '-message_types'][$active_name] ) ) {
259
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$active_name] );
257
+			foreach ($active_messengers as $messenger => $settings) {
258
+				if ( ! empty($settings['settings'][$messenger.'-message_types'][$active_name])) {
259
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$active_name]);
260 260
 				}
261 261
 			}
262
-			EEH_MSG_Template::update_to_inactive( '', $active_name );
263
-			if ( isset( $this->_active_message_types[$active_name] ) ) {
264
-				unset( $this->_active_message_types[$active_name] );
262
+			EEH_MSG_Template::update_to_inactive('', $active_name);
263
+			if (isset($this->_active_message_types[$active_name])) {
264
+				unset($this->_active_message_types[$active_name]);
265 265
 			}
266 266
 		}
267 267
 
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
 	 *
280 280
 	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
281 281
 	 */
282
-	private function _is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) {
282
+	private function _is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) {
283 283
 		$generating_msgrs = array();
284 284
 		//get the $messengers the message type says it can be used with.
285 285
 		$used_with = $message_type->with_messengers();
286 286
 
287
-		foreach ( $used_with as $generating_msgr => $secondary_msgrs ) {
288
-			if ( $messenger->name == $generating_msgr && isset( $this->_active_message_types[$generating_msgr][$message_type->name] ) ) {
287
+		foreach ($used_with as $generating_msgr => $secondary_msgrs) {
288
+			if ($messenger->name == $generating_msgr && isset($this->_active_message_types[$generating_msgr][$message_type->name])) {
289 289
 				return true;
290 290
 			}
291 291
 		}
@@ -305,17 +305,17 @@  discard block
 block discarded – undo
305 305
 	  * @param bool  $send 			       Default TRUE.  If false, then this will just return the generated EE_Messages objects which might be used by the trigger to setup a batch message (typically html messenger uses it).
306 306
 	 * @return bool
307 307
 	 */
308
-	public function send_message( $type, $vars, $sending_messenger = '', $generating_messenger='', $context='', $send = TRUE ) {
308
+	public function send_message($type, $vars, $sending_messenger = '', $generating_messenger = '', $context = '', $send = TRUE) {
309 309
 
310 310
 		$error = FALSE;
311 311
 		$installed_message_types = $this->get_installed_message_types();
312
-		$debug_index = 'Messages: ' . $type;
313
-		foreach ( $vars as $var ) {
314
-			if ( method_exists( $var, 'ID' ) ) {
315
-				$debug_index = get_class( $var ) .  ': ' . $var->ID();
312
+		$debug_index = 'Messages: '.$type;
313
+		foreach ($vars as $var) {
314
+			if (method_exists($var, 'ID')) {
315
+				$debug_index = get_class($var).': '.$var->ID();
316 316
 				break;
317
-			} else if ( is_object( $var )) {
318
-				$debug_index = spl_object_hash( $var );
317
+			} else if (is_object($var)) {
318
+				$debug_index = spl_object_hash($var);
319 319
 			}
320 320
 		}
321 321
 		//EEH_Debug_Tools::log(
@@ -334,34 +334,34 @@  discard block
 block discarded – undo
334 334
 		//);
335 335
 
336 336
 		// is that a real class ?
337
-		if ( isset(  $installed_message_types[$type] ) ) {
337
+		if (isset($installed_message_types[$type])) {
338 338
 			//is the messenger specified? If so then let's see if can send.  This is the check where its possible secondary messengers might be in use.
339
-			if ( !empty ( $sending_messenger ) ) {
340
-				$generating_messenger =  !empty( $generating_messenger ) && !empty( $this->_active_messengers[$generating_messenger] ) ? $this->_active_messengers[$generating_messenger]: NULL;
341
-				$generating_messenger = empty( $generating_messenger ) && ! empty( $this->_active_messengers[$sending_messenger] ) ? $this->_active_messengers[$sending_messenger] : $generating_messenger;
339
+			if ( ! empty ($sending_messenger)) {
340
+				$generating_messenger = ! empty($generating_messenger) && ! empty($this->_active_messengers[$generating_messenger]) ? $this->_active_messengers[$generating_messenger] : NULL;
341
+				$generating_messenger = empty($generating_messenger) && ! empty($this->_active_messengers[$sending_messenger]) ? $this->_active_messengers[$sending_messenger] : $generating_messenger;
342 342
 
343
-				if ( !$this->_is_generating_messenger_and_active( $generating_messenger, $installed_message_types[$type] ) ) {
343
+				if ( ! $this->_is_generating_messenger_and_active($generating_messenger, $installed_message_types[$type])) {
344 344
 					return false;
345 345
 				}
346
-				$sending_messenger = ! empty( $this->_active_messengers[$sending_messenger] ) ? $this->_active_messengers[$sending_messenger] : NULL;
346
+				$sending_messenger = ! empty($this->_active_messengers[$sending_messenger]) ? $this->_active_messengers[$sending_messenger] : NULL;
347 347
 
348
-				$context = !empty( $context ) ? $context : FALSE;
349
-				$success = $this->_send_message( $generating_messenger, $installed_message_types[$type], $vars, $sending_messenger, $context, $send );
350
-				if ( ! $send ) {
348
+				$context = ! empty($context) ? $context : FALSE;
349
+				$success = $this->_send_message($generating_messenger, $installed_message_types[$type], $vars, $sending_messenger, $context, $send);
350
+				if ( ! $send) {
351 351
 					return $success; //returning generated EE_Messages objects
352 352
 				}
353 353
 			} else {
354 354
 				//no messenger sent so let's just loop through active messengers (this method is only acceptable for primary messengers)
355 355
 				$send_messages = array();
356
-				foreach ( $this->_active_messengers as $active_messenger ) {
356
+				foreach ($this->_active_messengers as $active_messenger) {
357 357
 
358 358
 					//we ONLY continue if the given messenger is a primary messenger and is an active messenger for the given message type.  Otherwise we skip.
359
-					if ( ! $this->_is_generating_messenger_and_active( $active_messenger, $installed_message_types[$type] ) ) {
359
+					if ( ! $this->_is_generating_messenger_and_active($active_messenger, $installed_message_types[$type])) {
360 360
 						continue;
361 361
 					}
362 362
 
363
-					$success = $this->_send_message( $active_messenger, $installed_message_types[$type], $vars, $active_messenger );
364
-					if ( $success === FALSE  ) {
363
+					$success = $this->_send_message($active_messenger, $installed_message_types[$type], $vars, $active_messenger);
364
+					if ($success === FALSE) {
365 365
 						$error = TRUE;
366 366
 					} else {
367 367
 						$send_messages[] = $success;
@@ -381,17 +381,17 @@  discard block
 block discarded – undo
381 381
 				//	);
382 382
 
383 383
 				//return generated EE_Messages objects?
384
-				if ( ! $send ) {
384
+				if ( ! $send) {
385 385
 					return $send_messages;
386 386
 				}
387 387
 			}
388 388
 		} else {
389
-			EE_Error::add_error( sprintf( __('Message type: %s does not exist', 'event_espresso'), $type ), __FILE__, __FUNCTION__, __LINE__ );
389
+			EE_Error::add_error(sprintf(__('Message type: %s does not exist', 'event_espresso'), $type), __FILE__, __FUNCTION__, __LINE__);
390 390
 			return false;
391 391
 		}
392 392
 		// add a success message
393
-		if ( ! $error ) {
394
-			EE_Error::add_success( sprintf( __( 'The %s message has been successfully sent.', 'event_espresso'), $installed_message_types[$type]->label['singular'] ), __FILE__, __FUNCTION__, __LINE__ );
393
+		if ( ! $error) {
394
+			EE_Error::add_success(sprintf(__('The %s message has been successfully sent.', 'event_espresso'), $installed_message_types[$type]->label['singular']), __FILE__, __FUNCTION__, __LINE__);
395 395
 		}
396 396
 
397 397
 		return $error ? FALSE : TRUE; //yeah backwards eh?  Really what we're returning is if there is a total success for all the messages or not.  We'll modify this once we get message recording in place.
@@ -408,35 +408,35 @@  discard block
 block discarded – undo
408 408
 	 * @param bool 	$send true we will do a test send using the messenger delivery, false we just do a regular preview
409 409
 	 * @return string          The body of the message.
410 410
 	 */
411
-	public function preview_message( $type, $context, $messenger, $send = FALSE ) {
411
+	public function preview_message($type, $context, $messenger, $send = FALSE) {
412 412
 
413 413
 		$installed_message_types = $this->get_installed_message_types();
414 414
 
415 415
 		//does the given type match an actual message type class.
416
-		if ( isset(  $installed_message_types[$type] ) ) {
416
+		if (isset($installed_message_types[$type])) {
417 417
 			// valid messenger?
418
-			if ( isset( $this->_active_messengers[$messenger] ) ) {
418
+			if (isset($this->_active_messengers[$messenger])) {
419 419
 
420 420
 				//we ONLY continue if the given messenger has that message type active with it (note previews only come from primary messengers so no need to check secondarys)
421
-				if ( !isset( $this->_active_message_types[$messenger][$type] ) )
421
+				if ( ! isset($this->_active_message_types[$messenger][$type]))
422 422
 					return false;
423 423
 
424 424
 				$message = $installed_message_types[$type];
425 425
 				$messenger = $this->_active_messengers[$messenger];
426 426
 
427 427
 				//set data for preview
428
-				$message->set_messages( array(), $messenger, $context, TRUE );
428
+				$message->set_messages(array(), $messenger, $context, TRUE);
429 429
 
430 430
 				//let's GET the message body from the messenger (instead of the normal send_message)
431
-				return $messenger->get_preview( $message->messages[0], $message, $send );
431
+				return $messenger->get_preview($message->messages[0], $message, $send);
432 432
 
433 433
 			} else {
434
-				EE_Error::add_error( sprintf( __('Messenger: %s does not exist', 'event_espresso'), $messenger ), __FILE__, __FUNCTION__, __LINE__ );
434
+				EE_Error::add_error(sprintf(__('Messenger: %s does not exist', 'event_espresso'), $messenger), __FILE__, __FUNCTION__, __LINE__);
435 435
 				return FALSE;
436 436
 			}
437 437
 
438 438
 		} else {
439
-			EE_Error::add_error( sprintf( __('Message type: %s does not exist', 'event_espresso'), $type ), __FILE__, __FUNCTION__, __LINE__ );
439
+			EE_Error::add_error(sprintf(__('Message type: %s does not exist', 'event_espresso'), $type), __FILE__, __FUNCTION__, __LINE__);
440 440
 			return FALSE;
441 441
 		}
442 442
 
@@ -457,22 +457,22 @@  discard block
 block discarded – undo
457 457
 	 *
458 458
 	 * @return mixed(bool|std_Class[])
459 459
 	 */
460
-	private function _send_message( EE_messenger $generating_messenger, EE_message_type $message_type, $data, EE_messenger $sending_messenger, $context = FALSE, $send = TRUE ) {
460
+	private function _send_message(EE_messenger $generating_messenger, EE_message_type $message_type, $data, EE_messenger $sending_messenger, $context = FALSE, $send = TRUE) {
461 461
 		//can't even get started yo!
462
-		if ( $message_type === FALSE || is_wp_error( $message_type ) || $message_type->set_messages( $data, $generating_messenger, $context ) === FALSE ) {
462
+		if ($message_type === FALSE || is_wp_error($message_type) || $message_type->set_messages($data, $generating_messenger, $context) === FALSE) {
463 463
 			return FALSE;
464 464
 		}
465 465
 		// if the generating messenger and the sending messengers are different...
466 466
 		// then are there any hooks that the generating messenger sets for the sending messenger (i.e. css file swap outs etc.)
467
-		if ( $sending_messenger != $generating_messenger ) {
468
-			$generating_messenger->do_secondary_messenger_hooks( $sending_messenger->name );
467
+		if ($sending_messenger != $generating_messenger) {
468
+			$generating_messenger->do_secondary_messenger_hooks($sending_messenger->name);
469 469
 		}
470 470
 		//it is possible that the user has the messenger turned off for this type.
471
-		if ( $message_type->count === 0 ) {
471
+		if ($message_type->count === 0) {
472 472
 			return FALSE;
473 473
 		}
474 474
 		//are we just sending the EE_Messages stdClass objects back?
475
-		if ( ! $send ) {
475
+		if ( ! $send) {
476 476
 			return $message_type->messages;
477 477
 		}
478 478
 		//TODO: check count (at some point we'll use this to decide whether we send to queue or not i.e.
@@ -480,12 +480,12 @@  discard block
 block discarded – undo
480 480
 		//else...
481 481
 		$success = TRUE;
482 482
 		// $success is a flag for the loop.  If there is NO error then everything is a success (true) otherwise it wasn't a success (false)
483
-		foreach ( $message_type->messages as $message ) {
483
+		foreach ($message_type->messages as $message) {
484 484
 			//todo: should we do some reporting on messages gone out at some point?  I think we could have the $active_messenger object return bool for whether message was sent or not and we can compile a report based on that.
485 485
 			// if messages send successfully then $success retains it's value, but a single fail will toggle it to FALSE
486
-			$success = $sending_messenger->send_message( $message, $message_type ) === TRUE ? $success : FALSE;
486
+			$success = $sending_messenger->send_message($message, $message_type) === TRUE ? $success : FALSE;
487 487
 		}
488
-		unset( $message_type );
488
+		unset($message_type);
489 489
 		return $success;
490 490
 	}
491 491
 
@@ -504,24 +504,24 @@  discard block
 block discarded – undo
504 504
 	 *
505 505
 	 * @return bool          success or fail.
506 506
 	 */
507
-	public function send_message_with_messenger_only( $messenger, $message_type, $message ) {
507
+	public function send_message_with_messenger_only($messenger, $message_type, $message) {
508 508
 
509 509
 		//get EE_messenger object (which also checks if its active)
510
-		$msgr =  !empty( $messenger ) && !empty( $this->_active_messengers[$messenger] ) ? $this->_active_messengers[$messenger]: NULL;
510
+		$msgr = ! empty($messenger) && ! empty($this->_active_messengers[$messenger]) ? $this->_active_messengers[$messenger] : NULL;
511 511
 		$installed_message_types = $this->get_installed_message_types();
512 512
 
513
-		if ( ! $msgr instanceof EE_messenger ) {
513
+		if ( ! $msgr instanceof EE_messenger) {
514 514
 			return false; //can't do anything without a valid messenger.
515 515
 		}
516 516
 
517 517
 		//check valid message type
518
-		$mtype = isset(  $installed_message_types[$message_type] ) ? $installed_message_types[$message_type] : NULL;
518
+		$mtype = isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : NULL;
519 519
 
520
-		if( ! $mtype instanceof EE_message_type ) {
520
+		if ( ! $mtype instanceof EE_message_type) {
521 521
 			return false; //can't do anything without a valid message type.
522 522
 		}
523 523
 
524
-		return $msgr->send_message( $message, $mtype );
524
+		return $msgr->send_message($message, $mtype);
525 525
 	}
526 526
 
527 527
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 */
538 538
 	private function _validate_setup($messenger, $message_type, $is_global = FALSE) {
539 539
 
540
-		$message_type = strtolower(str_replace(' ', '_', $message_type) );
540
+		$message_type = strtolower(str_replace(' ', '_', $message_type));
541 541
 		$messenger = strtolower(str_replace(' ', '_', $messenger));
542 542
 		$installed_message_types = $this->get_installed_message_types();
543 543
 
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
 
554 554
 
555 555
 		//do we have the necessary objects loaded?
556
-		if ( empty( $this->_messenger) || empty($this->_message_type) )
557
-			throw new EE_Error( sprintf( __(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type ) );
556
+		if (empty($this->_messenger) || empty($this->_message_type))
557
+			throw new EE_Error(sprintf(__(' The %s messenger or the %s message_type are not active. Are you sure they exist?', 'event_espresso'), $messenger, $message_type));
558 558
 
559 559
 		//is given message_type valid for given messenger (if this is not a global save)
560 560
 		$types_to_check = array();
561
-		if ( !$is_global ) {
562
-			$has_active = EEM_Message_Template_Group::instance()->count( array( array( 'MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type ) ) );
561
+		if ( ! $is_global) {
562
+			$has_active = EEM_Message_Template_Group::instance()->count(array(array('MTP_is_active' => TRUE, 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $message_type)));
563 563
 
564
-			if ( $has_active == 0 ) {
565
-				EE_Error::add_error( sprintf(__(' The %s message type is not registered with the %s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'), $message_type, $messenger), __FILE__, __FUNCTION__, __LINE__ );
564
+			if ($has_active == 0) {
565
+				EE_Error::add_error(sprintf(__(' The %s message type is not registered with the %s messenger. Please visit the Messenger activation page to assign this message type first if you want to use it.', 'event_espresso'), $message_type, $messenger), __FILE__, __FUNCTION__, __LINE__);
566 566
 				return false;
567 567
 			}
568 568
 
@@ -575,17 +575,17 @@  discard block
 block discarded – undo
575 575
 	 * @param  string $message_type message type that the templates are being created for
576 576
 	 * @return array|object               if creation is succesful then we return an array of info, otherwise an error_object is returned.
577 577
 	 */
578
-	public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) {
578
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) {
579 579
 		$valid_mt = false;
580 580
 
581 581
 		$valid_mt = $this->_validate_setup($messenger, $message_type, $is_global);
582 582
 
583
-		if ( is_wp_error($valid_mt) && $is_global ) {
583
+		if (is_wp_error($valid_mt) && $is_global) {
584 584
 			//we're setting up a brand new global templates (with messenger activation) so we're assuming that the message types sent in are valid.
585 585
 			$valid_mt = true;
586 586
 		}
587 587
 
588
-		if ( is_wp_error($valid_mt) ) {
588
+		if (is_wp_error($valid_mt)) {
589 589
 			//if we've still got no valid_mt then bubble up error object
590 590
 			return $valid_mt;
591 591
 		}
@@ -597,10 +597,10 @@  discard block
 block discarded – undo
597 597
 	protected function _create_new_templates($GRP_ID, $is_global) {
598 598
 
599 599
 		//if we're creating a custom template then we don't need to use the defaults class
600
-		if ( ! $is_global )
601
-			return $this->_create_custom_template_group( $GRP_ID );
600
+		if ( ! $is_global)
601
+			return $this->_create_custom_template_group($GRP_ID);
602 602
 
603
-		$DFLT = new EE_Message_Template_Defaults( $this, $this->_messenger->name, $this->_message_type->name, $GRP_ID );
603
+		$DFLT = new EE_Message_Template_Defaults($this, $this->_messenger->name, $this->_message_type->name, $GRP_ID);
604 604
 
605 605
 		//generate templates
606 606
 		$success = $DFLT->create_new_templates();
@@ -628,16 +628,16 @@  discard block
 block discarded – undo
628 628
 	 *                                     			)
629 629
 	 * @access private
630 630
 	 */
631
-	private function _create_custom_template_group( $GRP_ID ) {
631
+	private function _create_custom_template_group($GRP_ID) {
632 632
 		//defaults
633
-		$success = array( 'GRP_ID' => NULL, 'MTP_context' => '' );
633
+		$success = array('GRP_ID' => NULL, 'MTP_context' => '');
634 634
 
635 635
 		//get the template group to use as a template from the db.  If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type.
636
-		$mtg = empty( $GRP_ID ) ? EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE ) ) ) : EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
636
+		$mtg = empty($GRP_ID) ? EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $this->_messenger->name, 'MTP_message_type' => $this->_message_type->name, 'MTP_is_global' => TRUE))) : EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
637 637
 
638 638
 		//if we don't have a mtg at this point then we need to bail.
639
-		if ( ! $mtg instanceof EE_Message_Template_Group ) {
640
-			EE_Error::add_error( sprintf( __('Something went wrong with generating the custom template from this group id: %s.  This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID ), __FILE__, __FUNCTION__, __LINE__ );
639
+		if ( ! $mtg instanceof EE_Message_Template_Group) {
640
+			EE_Error::add_error(sprintf(__('Something went wrong with generating the custom template from this group id: %s.  This usually happens when there is no matching message template group in the db.', 'event_espresso'), $GRP_ID), __FILE__, __FUNCTION__, __LINE__);
641 641
 			return $success;
642 642
 		}
643 643
 
@@ -649,27 +649,27 @@  discard block
 block discarded – undo
649 649
 		$new_mtg->set('GRP_ID', 0);
650 650
 		$new_mtg->set('MTP_is_global', FALSE);
651 651
 
652
-		$template_name = defined('DOING_AJAX') && !empty( $_POST['templateName'] ) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso');
653
-		$template_description = defined("DOING_AJAX") && !empty( $_POST['templateDescription'] ) ? $_POST['templateDescription'] : sprintf( __('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso' ), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular'] );
652
+		$template_name = defined('DOING_AJAX') && ! empty($_POST['templateName']) ? $_POST['templateName'] : __('New Custom Template', 'event_espresso');
653
+		$template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription']) ? $_POST['templateDescription'] : sprintf(__('This is a custom template that was created for the %s messenger and %s message type.', 'event_espresso'), $new_mtg->messenger_obj()->label['singular'], $new_mtg->message_type_obj()->label['singular']);
654 654
 
655 655
 
656
-		$new_mtg->set('MTP_name', $template_name );
657
-		$new_mtg->set('MTP_description', $template_description );
656
+		$new_mtg->set('MTP_name', $template_name);
657
+		$new_mtg->set('MTP_description', $template_description);
658 658
 		//remove ALL relations on this template group so they don't get saved!
659
-		$new_mtg->_remove_relations( 'Message_Template' );
659
+		$new_mtg->_remove_relations('Message_Template');
660 660
 		$new_mtg->save();
661 661
 		$success['GRP_ID'] = $new_mtg->ID();
662 662
 		$success['template_name'] = $template_name;
663 663
 
664 664
 		//add new message templates and add relation to.
665
-		foreach ( $mtts as $mtt ) {
666
-			if ( ! $mtt instanceof EE_Message_Template )
665
+		foreach ($mtts as $mtt) {
666
+			if ( ! $mtt instanceof EE_Message_Template)
667 667
 				continue;
668 668
 			$nmtt = clone $mtt;
669 669
 			$nmtt->set('MTP_ID', 0);
670
-			$nmtt->set( 'GRP_ID', $new_mtg->ID() ); //relation
670
+			$nmtt->set('GRP_ID', $new_mtg->ID()); //relation
671 671
 			$nmtt->save();
672
-			if ( empty( $success['MTP_context'] ) )
672
+			if (empty($success['MTP_context']))
673 673
 				$success['MTP_context'] = $nmtt->get('MTP_context');
674 674
 		}
675 675
 
@@ -694,14 +694,14 @@  discard block
 block discarded – undo
694 694
 
695 695
 
696 696
 		//okay now let's assemble an array with the messenger template fields added to the message_type contexts.
697
-		foreach ( $this->_message_type->get_contexts() as $context => $details ) {
698
-			foreach ( $this->_messenger->get_template_fields() as $field => $value ) {
697
+		foreach ($this->_message_type->get_contexts() as $context => $details) {
698
+			foreach ($this->_messenger->get_template_fields() as $field => $value) {
699 699
 				$template_fields[$context][$field] = $value;
700 700
 			}
701 701
 		}
702 702
 
703
-		if ( empty($template_fields) ) {
704
-			EE_Error::add_error( __('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
703
+		if (empty($template_fields)) {
704
+			EE_Error::add_error(__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
705 705
 			return FALSE;
706 706
 		}
707 707
 
@@ -716,30 +716,30 @@  discard block
 block discarded – undo
716 716
 	 * @param bool  $set if true then we skip the cache and retrieve via files.
717 717
 	 * @return array multidimensional array of messenger and message_type objects (messengers index, and message_type index);
718 718
 	 */
719
-	public function get_installed( $type = 'all', $skip_cache = false ) {
719
+	public function get_installed($type = 'all', $skip_cache = false) {
720 720
 		$installed = array();
721 721
 
722 722
 		//first let's account for caching
723
-		if ( $skip_cache ) {
724
-			$message_base = EE_LIBRARIES . "messages" . DS;
723
+		if ($skip_cache) {
724
+			$message_base = EE_LIBRARIES."messages".DS;
725 725
 
726
-			$messenger_files = $type == 'all' || $type == 'messengers' ? scandir( $message_base . "messenger", 1) : NULL;
727
-			$messagetype_files = $type == 'all' || $type == 'message_types' ? scandir( $message_base . "message_type", 1) : NULL;
726
+			$messenger_files = $type == 'all' || $type == 'messengers' ? scandir($message_base."messenger", 1) : NULL;
727
+			$messagetype_files = $type == 'all' || $type == 'message_types' ? scandir($message_base."message_type", 1) : NULL;
728 728
 
729 729
 
730 730
 			//allow plugins to filter in their messenger/message_type files
731
-			$messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type );
732
-			$messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type );
731
+			$messenger_files = apply_filters('FHEE__EE_messages__get_installed__messenger_files', $messenger_files, $type);
732
+			$messagetype_files = apply_filters('FHEE__EE_messages__get_installed__messagetype_files', $messagetype_files, $type);
733 733
 
734
-			$installed['messengers'] = !empty($messenger_files ) ? $this->_get_installed($messenger_files) : '';
735
-			$installed['message_types'] = !empty($messagetype_files) ? $this->_get_installed($messagetype_files) : '';
734
+			$installed['messengers'] = ! empty($messenger_files) ? $this->_get_installed($messenger_files) : '';
735
+			$installed['message_types'] = ! empty($messagetype_files) ? $this->_get_installed($messagetype_files) : '';
736 736
 		} else {
737 737
 			$installed['messengers'] = $this->get_installed_messengers();
738 738
 			$installed['message_types'] = $this->get_installed_message_types();
739 739
 		}
740 740
 
741 741
 
742
-		if ( $type != 'all' ) {
742
+		if ($type != 'all') {
743 743
 			$installed = $type == 'messengers' ? $installed['messengers'] : $installed['message_types'];
744 744
 		}
745 745
 
@@ -757,11 +757,11 @@  discard block
 block discarded – undo
757 757
 		$the_goods = array();
758 758
 		$filenames = (array) $filenames;
759 759
 		$replace = ".class.php";
760
-		foreach ( $filenames as $filename ) {
761
-			$classname = preg_match("/" . $replace . "/", $filename ) ? str_replace($replace, "", $filename) : false;
760
+		foreach ($filenames as $filename) {
761
+			$classname = preg_match("/".$replace."/", $filename) ? str_replace($replace, "", $filename) : false;
762 762
 
763 763
 			//no classname? no match? move along, nothing to see here. note, the stripos is checking to make sure the filename (classname) begins with EE.
764
-			if ( !$classname || 0 !== stripos($classname, 'EE') ) continue;
764
+			if ( ! $classname || 0 !== stripos($classname, 'EE')) continue;
765 765
 
766 766
 			//note: I'm not sure if this will work without including the file.  We do have autoloaders so it "may" work.
767 767
 			$a = new ReflectionClass($classname);
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 	 */
785 785
 	public function get_active_message_types() {
786 786
 		$message_types = array();
787
-		foreach ( $this->_active_message_types as $messenger => $mtvalues ) {
788
-			foreach ( $mtvalues as $mt => $config ) {
789
-				if ( !in_array( $mt, $message_types ) )
787
+		foreach ($this->_active_message_types as $messenger => $mtvalues) {
788
+			foreach ($mtvalues as $mt => $config) {
789
+				if ( ! in_array($mt, $message_types))
790 790
 					$message_types[] = $mt;
791 791
 			}
792 792
 		}
@@ -806,17 +806,17 @@  discard block
 block discarded – undo
806 806
 	 *
807 807
 	 * @return EE_message_type[]    (or empty array if none present)
808 808
 	 */
809
-	public function get_active_message_types_per_messenger( $messenger ) {
809
+	public function get_active_message_types_per_messenger($messenger) {
810 810
 		$messenger = (string) $messenger;
811
-		if ( empty( $this->_active_message_types[$messenger] ) ) {
811
+		if (empty($this->_active_message_types[$messenger])) {
812 812
 			return array();
813 813
 		}
814 814
 
815 815
 		$mts = array();
816 816
 		$message_types = $this->_active_message_types[$messenger];
817 817
 		$installed_message_types = $this->get_installed_message_types();
818
-		foreach ( $message_types as $mt => $settings ) {
819
-			if ( ! empty( $installed_message_types[$mt] ) )  {
818
+		foreach ($message_types as $mt => $settings) {
819
+			if ( ! empty($installed_message_types[$mt])) {
820 820
 				$mts[] = $installed_message_types[$mt];
821 821
 			}
822 822
 		}
@@ -833,9 +833,9 @@  discard block
 block discarded – undo
833 833
 	 *
834 834
 	 * @return EE_Message_Type|null
835 835
 	 */
836
-	public function get_active_message_type( $messenger, $message_type ) {
836
+	public function get_active_message_type($messenger, $message_type) {
837 837
 		$installed_message_types = $this->get_installed_message_types();
838
-		if ( !empty( $this->_active_message_types[$messenger][$message_type] ) && !empty( $installed_message_types[$message_type] ) )  {
838
+		if ( ! empty($this->_active_message_types[$messenger][$message_type]) && ! empty($installed_message_types[$message_type])) {
839 839
 			return $installed_message_types[$message_type];
840 840
 		}
841 841
 		return NULL;
@@ -844,13 +844,13 @@  discard block
 block discarded – undo
844 844
 
845 845
 
846 846
 	public function get_installed_message_types() {
847
-		$this->_installed_message_types = empty( $this->_installed_message_types ) ? $this->get_installed( 'message_types', true ) : $this->_installed_message_types;
847
+		$this->_installed_message_types = empty($this->_installed_message_types) ? $this->get_installed('message_types', true) : $this->_installed_message_types;
848 848
 		return $this->_installed_message_types;
849 849
 	}
850 850
 
851 851
 
852 852
 	public function get_installed_messengers() {
853
-		$this->_installed_messengers = empty( $this->_installed_messengers ) ? $this->get_installed( 'messengers', true ) : $this->_installed_messengers;
853
+		$this->_installed_messengers = empty($this->_installed_messengers) ? $this->get_installed('messengers', true) : $this->_installed_messengers;
854 854
 		return $this->_installed_messengers;
855 855
 	}
856 856
 }
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.
core/libraries/messages/defaults/EE_Messages_Template_Pack.core.php 2 patches
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -167,48 +167,48 @@  discard block
 block discarded – undo
167 167
 	public function __construct() {
168 168
 		$this->_set_props();
169 169
 		//make sure classname is correct
170
-		$classname = get_class( $this );
170
+		$classname = get_class($this);
171 171
 		//make sure required props have been set
172 172
 
173 173
 		//if label is empty then throw an error because we should have it defined by now.
174
-		if ( ! isset( $this->label )  ) {
175
-			throw new EE_Error( sprintf( __('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso' ), $classname ) );
174
+		if ( ! isset($this->label)) {
175
+			throw new EE_Error(sprintf(__('The label property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
176 176
 		}
177 177
 
178 178
 
179 179
 		//the reference for this template pack
180
-		if ( ! isset( $this->dbref )  ) {
181
-			throw new EE_Error( sprintf( __('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso' ), $classname ) );
180
+		if ( ! isset($this->dbref)) {
181
+			throw new EE_Error(sprintf(__('The dbref property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
182 182
 		}
183 183
 
184 184
 		//make sure dbref is safe
185
-		$this->dbref = str_replace( '-', '_', sanitize_key( $this->dbref ) );
185
+		$this->dbref = str_replace('-', '_', sanitize_key($this->dbref));
186 186
 
187
-		$should_be = 'EE_Messages_Template_Pack_' . str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $this->dbref ) ) );
187
+		$should_be = 'EE_Messages_Template_Pack_'.str_replace(' ', '_', ucwords(str_replace('_', ' ', $this->dbref)));
188 188
 
189
-		if ( $should_be !== $classname ) {
190
-			throw new EE_Error( sprintf( __('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso' ), $classname, $should_be ) );
189
+		if ($should_be !== $classname) {
190
+			throw new EE_Error(sprintf(__('The name of the template pack instantiated class is "%s".  It should be "%s".  Make sure that the name of the template pack class matches is prepended with "EE_Messages_Template_Pack_" and appended with a sentence case iteration of the value for your template pack\'s dbref property.', 'event_espresso'), $classname, $should_be));
191 191
 		}
192 192
 
193 193
 		//if _base_path is not set then throw an error because a base path string is needed.
194
-		if ( empty( $this->_base_path ) ) {
195
-			throw new EE_Error( sprintf( __('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso' ), $classname ) );
194
+		if (empty($this->_base_path)) {
195
+			throw new EE_Error(sprintf(__('The _base_path property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
196 196
 		}
197 197
 
198 198
 
199 199
 		//if _base_url is not set then throw an error because a  string is needed for variations.
200
-		if ( empty( $this->_base_url ) ) {
201
-			throw new EE_Error( sprintf( __('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso' ), $classname ) );
200
+		if (empty($this->_base_url)) {
201
+			throw new EE_Error(sprintf(__('The _base_url property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
202 202
 		}
203 203
 
204 204
 
205 205
 		//if $supports is not set then throw an error because that effectively means this template_pack does not have any templates!
206
-		if ( empty( $this->_supports ) ) {
207
-			throw new EE_Error( sprintf( __('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso' ), $classname ) );
206
+		if (empty($this->_supports)) {
207
+			throw new EE_Error(sprintf(__('The supports property is not set for %s.  Please ensure that is set for the class.', 'event_espresso'), $classname));
208 208
 		}
209 209
 
210 210
 		//load template helper
211
-		EE_Registry::instance()->load_helper( 'Template' );
211
+		EE_Registry::instance()->load_helper('Template');
212 212
 
213 213
 	}
214 214
 
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
 	 *
244 244
 	 * @return array
245 245
 	 */
246
-	public function get_templates( EE_messenger $messenger, EE_message_type $message_type ) {
247
-		return isset( $this->_templates[$messenger->name][$message_type->name] ) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates( $messenger, $message_type );
246
+	public function get_templates(EE_messenger $messenger, EE_message_type $message_type) {
247
+		return isset($this->_templates[$messenger->name][$message_type->name]) ? $this->_templates[$messenger->name][$message_type->name] : $this->_get_templates($messenger, $message_type);
248 248
 	}
249 249
 
250 250
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * @return array          Returns an multi-level associative array indexed by template context and field in the format:
262 262
 	 *                                array( 'context' => array( 'field' => 'value', 'another-field', 'value' ) );
263 263
 	 */
264
-	protected function _get_templates( EE_messenger $messenger, EE_message_type $message_type ) {
264
+	protected function _get_templates(EE_messenger $messenger, EE_message_type $message_type) {
265 265
 		$templates = array();
266 266
 
267 267
 		/**
@@ -280,28 +280,28 @@  discard block
 block discarded – undo
280 280
 		$contexts = $message_type->get_contexts();
281 281
 
282 282
 
283
-		foreach ( $contexts as $context => $details ) {
284
-			foreach ( $fields as $field => $field_details ) {
285
-				if ( empty( $field_details ) )
283
+		foreach ($contexts as $context => $details) {
284
+			foreach ($fields as $field => $field_details) {
285
+				if (empty($field_details))
286 286
 					continue;
287 287
 				/**
288 288
 				 * is this a field array (linked to a main field)?
289 289
 				 */
290
-				if ( $field == 'extra'  ) {
291
-					foreach ( $field_details as $main_field => $sub_fields ) {
292
-						foreach ( $sub_fields as $sub_field => $sub_field_details ) {
290
+				if ($field == 'extra') {
291
+					foreach ($field_details as $main_field => $sub_fields) {
292
+						foreach ($sub_fields as $sub_field => $sub_field_details) {
293 293
 							//make sure that the template_field_ref matches what the main template field is for this template group.
294 294
 							$template_field_ref = $sub_field == 'main' ? $main_field : $sub_field;
295
-							$templates[ $context ][ $main_field ][ $sub_field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $template_field_ref, $context );
295
+							$templates[$context][$main_field][$sub_field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $template_field_ref, $context);
296 296
 						}
297 297
 					}
298 298
 				} else {
299
-					$templates[ $context ][ $field ] = $this->_get_specific_template( $default_pack, $messenger, $message_type, $field, $context );
299
+					$templates[$context][$field] = $this->_get_specific_template($default_pack, $messenger, $message_type, $field, $context);
300 300
 				}
301 301
 			}
302 302
 		}
303 303
 
304
-		$templates = apply_filters( 'FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this );
304
+		$templates = apply_filters('FHEE__EE_Template_Pack___get_templates__templates', $templates, $messenger, $message_type, $this);
305 305
 
306 306
 		$this->_templates[$messenger->name][$message_type->name] = $templates;
307 307
 		 return $templates;
@@ -319,22 +319,22 @@  discard block
 block discarded – undo
319 319
 	 *
320 320
 	 * @return string          The template contents.
321 321
 	 */
322
-	protected function _get_specific_template( $default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context ) {
322
+	protected function _get_specific_template($default_pack, EE_messenger $messenger, EE_message_type $message_type, $field, $context) {
323 323
 
324 324
 		//default templates
325
-		$default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates( $messenger, $message_type ) : array();
325
+		$default_templates = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_templates($messenger, $message_type) : array();
326 326
 
327 327
 		//first we allow for the $_base_path to be filtered.  However, we assign this to a new variable so that we have the original base_path as a fallback.
328
-		$filtered_base_path = apply_filters( 'FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this );
328
+		$filtered_base_path = apply_filters('FHEE__EE_Template_Pack___get_specific_template__filtered_base_path', $this->_base_path, $messenger, $message_type, $field, $context, $this);
329 329
 
330 330
 		$master_templates = $message_type->get_master_templates();
331
-		$master_templates_mt = isset( $master_templates[$messenger->name] ) ? $master_templates[$messenger->name] : $message_type->name;
332
-		$full_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '_' . $context . '.template.php';
333
-		$fallback_path = $filtered_base_path . $messenger->name . '_' . $message_type->name . '_' . $field . '.template.php';
334
-		$mt_defined_full_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
335
-		$mt_defined_fallback_path = $filtered_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
336
-		$base_defined_full_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '_' . $context . '.template.php';
337
-		$base_defined_fallback_path = $this->_base_path . $messenger->name . '_' . $master_templates_mt . '_' . $field . '.template.php';
331
+		$master_templates_mt = isset($master_templates[$messenger->name]) ? $master_templates[$messenger->name] : $message_type->name;
332
+		$full_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'_'.$context.'.template.php';
333
+		$fallback_path = $filtered_base_path.$messenger->name.'_'.$message_type->name.'_'.$field.'.template.php';
334
+		$mt_defined_full_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
335
+		$mt_defined_fallback_path = $filtered_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
336
+		$base_defined_full_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'_'.$context.'.template.php';
337
+		$base_defined_fallback_path = $this->_base_path.$messenger->name.'_'.$master_templates_mt.'_'.$field.'.template.php';
338 338
 
339 339
 		/**
340 340
 		 * Template checks are done hierarchically in the following order:
@@ -348,28 +348,28 @@  discard block
 block discarded – undo
348 348
 		 */
349 349
 
350 350
 
351
-		if ( is_readable( $full_path ) ) {
351
+		if (is_readable($full_path)) {
352 352
 			$actual_path = $full_path;
353
-		} elseif ( is_readable( $fallback_path ) ) {
353
+		} elseif (is_readable($fallback_path)) {
354 354
 			$actual_path = $fallback_path;
355
-		} elseif ( is_readable( $mt_defined_full_path ) ) {
355
+		} elseif (is_readable($mt_defined_full_path)) {
356 356
 			$actual_path = $mt_defined_full_path;
357
-		} elseif ( is_readable( $mt_defined_fallback_path ) ) {
357
+		} elseif (is_readable($mt_defined_fallback_path)) {
358 358
 			$actual_path = $mt_defined_fallback_path;
359
-		} elseif ( is_readable( $base_defined_full_path ) ) {
359
+		} elseif (is_readable($base_defined_full_path)) {
360 360
 			$actual_path = $base_defined_full_path;
361
-		} elseif ( is_readable( $base_defined_fallback_path ) ) {
361
+		} elseif (is_readable($base_defined_fallback_path)) {
362 362
 			$actual_path = $base_defined_fallback_path;
363
-		} else  {
363
+		} else {
364 364
 			$actual_path = '';
365 365
 		}
366
-		if ( empty( $actual_path ) ) {
367
-			$contents = isset( $default_templates[$context][$field] ) ? $default_templates[$context][$field] : '';
366
+		if (empty($actual_path)) {
367
+			$contents = isset($default_templates[$context][$field]) ? $default_templates[$context][$field] : '';
368 368
 		} else {
369
-			$contents = EEH_Template::display_template( $actual_path, array(), TRUE );
369
+			$contents = EEH_Template::display_template($actual_path, array(), TRUE);
370 370
 		}
371 371
 
372
-		return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this );
372
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', $contents, $actual_path, $messenger, $message_type, $field, $context, $this);
373 373
 	}
374 374
 
375 375
 
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 	 * @return array
385 385
 	 */
386 386
 	public function get_supports() {
387
-		$supports = apply_filters( 'FHEE__' . get_class( $this ) . '__get_supports', $this->_supports );
388
-		return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this );
387
+		$supports = apply_filters('FHEE__'.get_class($this).'__get_supports', $this->_supports);
388
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_supports', $supports, $this);
389 389
 	}
390 390
 
391 391
 
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @return array|string
402 402
 	 */
403
-	public function get_default_variation_labels( $messenger = '' ) {
404
-		$label = empty( $messenger ) ? $this->_default_variation_labels : array();
405
-		$label = empty( $label ) && ! empty( $this->_default_variation_labels[$messenger] ) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso');
403
+	public function get_default_variation_labels($messenger = '') {
404
+		$label = empty($messenger) ? $this->_default_variation_labels : array();
405
+		$label = empty($label) && ! empty($this->_default_variation_labels[$messenger]) ? $this->_default_variation_labels[$messenger] : __('Default', 'event_espresso');
406 406
 
407
-		return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger );
407
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_default_variation_labels', $label, $this->_default_variation_labels, $messenger);
408 408
 	}
409 409
 
410 410
 
@@ -420,25 +420,25 @@  discard block
 block discarded – undo
420 420
 	 * @param string $message_type if included then css variations matching the message_type are returned (must have $messenger set).  Otherwise the array of variations per message type are returned.  If message_type is provided but NOT the messenger, then just all variations for all messengers are returned.
421 421
 	 * @return array
422 422
 	 */
423
-	public function get_variations( $messenger = '', $message_type = '' ) {
424
-		$messenger_variations = ! empty( $messenger ) && isset( $this->_variations[$messenger] ) ? $this->_variations[$messenger] : array();
423
+	public function get_variations($messenger = '', $message_type = '') {
424
+		$messenger_variations = ! empty($messenger) && isset($this->_variations[$messenger]) ? $this->_variations[$messenger] : array();
425 425
 
426 426
 		//message_type provided? IF so, then we've requested a specific set of variations, so we need to make sure we set it as empty if that's not present.
427
-		$variations = !empty( $messenger ) && !empty( $message_type ) && isset( $messenger_variations[$message_type] ) ? $messenger_variations[$message_type] : array();
427
+		$variations = ! empty($messenger) && ! empty($message_type) && isset($messenger_variations[$message_type]) ? $messenger_variations[$message_type] : array();
428 428
 
429 429
 		//now let's account for the possibility we just want all the variations for a messenger (which is indicated by providing the messenger but not the message type).
430
-		$variations = empty( $variations ) && !empty( $messenger ) && empty( $message_type ) ? $messenger_variations : $variations;
430
+		$variations = empty($variations) && ! empty($messenger) && empty($message_type) ? $messenger_variations : $variations;
431 431
 
432 432
 		//filter per template pack and globally.
433
-		$variations = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variations', $variations, $messenger, $message_type );
434
-		$variations = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this );
433
+		$variations = apply_filters('FHEE__'.get_class($this).'__get_variations', $variations, $messenger, $message_type);
434
+		$variations = apply_filters('FHEE__EE_Messages_Template_Pack__get_variations', $variations, $messenger, $message_type, $this);
435 435
 
436 436
 		//prepend the _default_variation, but ONLY if we're returning the fully validated array.
437
-		if ( !empty( $messenger ) && !empty( $message_type ) && ! empty( $variations ) ) {
438
-			$variations = array( 'default' => $this->get_default_variation_labels( $messenger ) ) + $variations;
437
+		if ( ! empty($messenger) && ! empty($message_type) && ! empty($variations)) {
438
+			$variations = array('default' => $this->get_default_variation_labels($messenger)) + $variations;
439 439
 		}
440 440
 
441
-		return empty( $variations ) ? array( 'default' => $this->get_default_variation_labels('dft') ): $variations;
441
+		return empty($variations) ? array('default' => $this->get_default_variation_labels('dft')) : $variations;
442 442
 	}
443 443
 
444 444
 
@@ -459,39 +459,39 @@  discard block
 block discarded – undo
459 459
 	 *
460 460
 	 * @return string The variation path or url (typically css reference)
461 461
 	 */
462
-	public function get_variation( $messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE ) {
462
+	public function get_variation($messenger, $message_type, $type, $variation, $url = true, $file_extension = '.css', $skip_filters = FALSE) {
463 463
 
464 464
 		$base = $url ? $this->_base_url : $this->_base_path;
465 465
 		$base_path = $this->_base_path;
466 466
 
467
-		if ( ! $skip_filters ) {
468
-			$base =  apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this );
469
-			$base_path = apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this );
467
+		if ( ! $skip_filters) {
468
+			$base = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path_or_url', $base, $messenger, $message_type, $type, $variation, $url, $file_extension, $this);
469
+			$base_path = apply_filters('FHEE__EE_Messages_Template_Pack__get_variation__base_path', $base_path, $messenger, $message_type, $type, $variation, FALSE, $file_extension, $this);
470 470
 		}
471 471
 
472
-		$default_pack = get_class( $this ) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
472
+		$default_pack = get_class($this) != 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : $this;
473 473
 
474 474
 		//possible variation paths considering whether message type is present or not in the file name.
475
-		$path_string = 'variations/' . $messenger . '_' . $message_type . '_'  . $type . '_' . $variation . $file_extension;
476
-		$default_path_string = 'variations/' . $messenger . '_' . $type . '_' . $variation . $file_extension;
475
+		$path_string = 'variations/'.$messenger.'_'.$message_type.'_'.$type.'_'.$variation.$file_extension;
476
+		$default_path_string = 'variations/'.$messenger.'_'.$type.'_'.$variation.$file_extension;
477 477
 
478 478
 		//first see if fully validated file exists.
479
-		if ( is_readable( $base_path . $path_string ) ) {
480
-			$variation_path = $base . $path_string;
479
+		if (is_readable($base_path.$path_string)) {
480
+			$variation_path = $base.$path_string;
481 481
 		//otherwise see if default exists.
482
-		} elseif ( is_readable( $base_path . $default_path_string ) ) {
483
-			$variation_path = $base . $default_path_string;
482
+		} elseif (is_readable($base_path.$default_path_string)) {
483
+			$variation_path = $base.$default_path_string;
484 484
 		} else {
485
-			$variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation( $messenger, $message_type, $type, $url, $file_extension ) : '';
485
+			$variation_path = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_default_variation($messenger, $message_type, $type, $url, $file_extension) : '';
486 486
 		}
487 487
 
488
-		if ( $skip_filters ) {
488
+		if ($skip_filters) {
489 489
 			return $variation_path;
490 490
 		}
491 491
 
492 492
 		//filter result
493
-		$variation_path = apply_filters( 'FHEE__' . get_class( $this ) . '__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url );
494
-		return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this );
493
+		$variation_path = apply_filters('FHEE__'.get_class($this).'__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url);
494
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_variation', $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, $this);
495 495
 	}
496 496
 
497 497
 
@@ -506,19 +506,19 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @return string returns the path for the requested wrapper template.
508 508
 	 */
509
-	public function get_wrapper( $messenger, $type = 'main' ) {
510
-		$default_pack = get_class( $this ) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL;
509
+	public function get_wrapper($messenger, $type = 'main') {
510
+		$default_pack = get_class($this) !== 'EE_Messages_Template_Pack_Default' ? new EE_Messages_Template_Pack_Default() : NULL;
511 511
 
512
-		$path_string = $this->_base_path . $messenger . '_' . $type . '_wrapper.template.php';
512
+		$path_string = $this->_base_path.$messenger.'_'.$type.'_wrapper.template.php';
513 513
 
514
-		if ( is_readable( $path_string ) ) {
514
+		if (is_readable($path_string)) {
515 515
 			$template = $path_string;
516 516
 		} else {
517
-			$template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper( $messenger, $type ) : '';
517
+			$template = $default_pack instanceof EE_Messages_Template_Pack_Default ? $default_pack->get_wrapper($messenger, $type) : '';
518 518
 		}
519 519
 
520 520
 		//filter
521
-		$template = apply_filters( 'FHEE__' . get_class( $this ) . '__get_wrapper', $template, $messenger, $type );
522
-		return apply_filters( 'FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this );
521
+		$template = apply_filters('FHEE__'.get_class($this).'__get_wrapper', $template, $messenger, $type);
522
+		return apply_filters('FHEE__EE_Messages_Template_Pack__get_wrapper', $template, $messenger, $type, $this);
523 523
 	}
524 524
 }
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@  discard block
 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
  * EE_Template_Packs are classes that contain all the information related to messages templates for a given "template pack".
@@ -282,8 +284,9 @@  discard block
 block discarded – undo
282 284
 
283 285
 		foreach ( $contexts as $context => $details ) {
284 286
 			foreach ( $fields as $field => $field_details ) {
285
-				if ( empty( $field_details ) )
286
-					continue;
287
+				if ( empty( $field_details ) ) {
288
+									continue;
289
+				}
287 290
 				/**
288 291
 				 * is this a field array (linked to a main field)?
289 292
 				 */
Please login to merge, or discard this patch.