@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @since 4.6 |
9 | 9 | * |
10 | 10 | */ |
11 | -abstract class EE_Validation_Strategy_Base extends EE_Form_Input_Strategy_Base{ |
|
11 | +abstract class EE_Validation_Strategy_Base extends EE_Form_Input_Strategy_Base { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | protected $_validation_error_message = ''; |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @param null $validation_error_message |
20 | 20 | */ |
21 | - public function __construct( $validation_error_message = NULL ) { |
|
22 | - $this->_validation_error_message = $validation_error_message === NULL ? __( 'Input invalid', 'event_espresso' ) : $validation_error_message ; |
|
21 | + public function __construct($validation_error_message = NULL) { |
|
22 | + $this->_validation_error_message = $validation_error_message === NULL ? __('Input invalid', 'event_espresso') : $validation_error_message; |
|
23 | 23 | parent::__construct(); |
24 | 24 | } |
25 | 25 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @param mixed $normalized_value ready for validation. May very well be NULL (which, unless |
35 | 35 | * this validation strategy is the 'required' validation strategy, most should be OK with a null, empty string, etc) |
36 | 36 | */ |
37 | - function validate($normalized_value){ |
|
37 | + function validate($normalized_value) { |
|
38 | 38 | //by default, the validation strategy does no validation. this should be implemented |
39 | 39 | } |
40 | 40 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - function get_jquery_validation_rule_array(){ |
|
61 | + function get_jquery_validation_rule_array() { |
|
62 | 62 | return array(); |
63 | 63 | } |
64 | 64 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * the input is invalid. Used for both frontend and backend validation. |
68 | 68 | * @return string |
69 | 69 | */ |
70 | - function get_validation_error_message(){ |
|
70 | + function get_validation_error_message() { |
|
71 | 71 | return $this->_validation_error_message; |
72 | 72 | } |
73 | 73 | } |
74 | 74 | \ No newline at end of file |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Line_Item_Display |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * @since $VID:$ |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Line_Item_Display |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * @since $VID:$ |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Line_Item_Display { |
15 | 15 | |
16 | 16 | private $strategy = NULL; |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @param $context - where/how the line items are being displayed |
20 | 20 | */ |
21 | - public function __construct( $context ) { |
|
22 | - $context = strtolower( $context ); |
|
23 | - switch ( $context ) { |
|
21 | + public function __construct($context) { |
|
22 | + $context = strtolower($context); |
|
23 | + switch ($context) { |
|
24 | 24 | case 'invoice' : |
25 | 25 | $this->strategy = new EE_Invoice_Line_Item_Display_Strategy(); |
26 | 26 | break; |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @param array $options |
41 | 41 | * @return mixed |
42 | 42 | */ |
43 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
44 | - return $this->strategy->display_line_item( $line_item, $options ); |
|
43 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
44 | + return $this->strategy->display_line_item($line_item, $options); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $options |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ); |
|
61 | + public function display_line_item(EE_Line_Item $line_item, $options = array()); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | // End of file EE_Line_Item_Display.class.php |
@@ -1,16 +1,16 @@ |
||
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 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @param EE_Line_Item $line_item |
21 | 21 | * @param array $options |
22 | - * @return mixed |
|
22 | + * @return string |
|
23 | 23 | */ |
24 | 24 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
25 | 25 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @param EE_Line_Item $line_item |
104 | 104 | * @param array $options |
105 | - * @return mixed |
|
105 | + * @return string |
|
106 | 106 | */ |
107 | 107 | private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
108 | 108 | // start of row |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @param EE_Line_Item $line_item |
145 | 145 | * @param array $options |
146 | - * @return mixed |
|
146 | + * @return string |
|
147 | 147 | */ |
148 | 148 | private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
149 | 149 | // start of row |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param EE_Line_Item $line_item |
175 | 175 | * @param array $options |
176 | - * @return mixed |
|
176 | + * @return string |
|
177 | 177 | */ |
178 | 178 | private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
179 | 179 | // start of row |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | * @param EE_Line_Item $line_item |
201 | 201 | * @param string $text |
202 | 202 | * @param array $options |
203 | - * @return mixed |
|
203 | + * @return string |
|
204 | 204 | */ |
205 | 205 | private function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
206 | 206 | if ( $line_item->total() ) { |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | * @param EE_Line_Item $line_item |
218 | 218 | * @param string $text |
219 | 219 | * @param array $options |
220 | - * @return mixed |
|
220 | + * @return string |
|
221 | 221 | */ |
222 | 222 | private function _total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
223 | 223 | $html = ''; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * _payments_and_amount_owing_rows |
241 | 241 | * |
242 | 242 | * @param EE_Line_Item $line_item |
243 | - * @return mixed |
|
243 | + * @return string |
|
244 | 244 | */ |
245 | 245 | private function _payments_and_amount_owing_rows( EE_Line_Item $line_item ) { |
246 | 246 | $html = ''; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | * _separator_row |
289 | 289 | * |
290 | 290 | * @param array $options |
291 | - * @return mixed |
|
291 | + * @return string |
|
292 | 292 | */ |
293 | 293 | private function _separator_row( $options = array() ) { |
294 | 294 | // start of row |
@@ -21,73 +21,73 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -185,14 +185,14 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -209,8 +210,9 @@ discard block |
||
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 |
||
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) ) ) ) { |
@@ -39,31 +39,31 @@ discard block |
||
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 |
||
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 | /** |
@@ -6,7 +6,9 @@ |
||
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. |
@@ -6,7 +6,9 @@ discard block |
||
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 |
||
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 | } |
@@ -29,9 +29,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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(); |
@@ -382,12 +382,12 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @param EE_messenger $active_messenger The active messenger being used |
260 | 260 | * @param string $context if present then a message is only being generated for a specific context |
261 | 261 | * @param bool $preview indicate whether a preview is being generated or not. |
262 | - * @return void |
|
262 | + * @return false|null |
|
263 | 263 | */ |
264 | 264 | public function set_messages($data, EE_messenger $active_messenger, $context = '', $preview = FALSE ) { |
265 | 265 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param string $action the page action (to allow for more specific handling - i.e. edit vs. add pages) |
502 | 502 | * @param array $extra This is just an extra argument that can be used to pass additional data for setting up page content. |
503 | 503 | * @access public |
504 | - * @return void |
|
504 | + * @return string |
|
505 | 505 | */ |
506 | 506 | public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) { |
507 | 507 | //we can also further refine the context by action (if present). |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * The main purpose of this function is to setup the various parameters within the message_type. $this->addressees, $this->_templates, $this->count, and any extra stuff to the data object that can come from the message_type template options. |
561 | 561 | * Child classes might overwrite this if they aren't expecting EE_Session as the incoming data object. |
562 | 562 | * |
563 | - * @return void |
|
563 | + * @return boolean |
|
564 | 564 | * @access protected |
565 | 565 | */ |
566 | 566 | protected function _init_data() { |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | |
603 | 603 | /** |
604 | 604 | * processes the data object so we get |
605 | - * @return void |
|
605 | + * @return boolean |
|
606 | 606 | */ |
607 | 607 | protected function _process_data() { |
608 | 608 | //at a minimum, we NEED EE_Attendee objects. |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | * Takes care of setting up the addressee object(s) for the primary attendee. |
754 | 754 | * |
755 | 755 | * @access protected |
756 | - * @return array of EE_Addressee objects |
|
756 | + * @return EE_Messages_Addressee[] of EE_Addressee objects |
|
757 | 757 | */ |
758 | 758 | protected function _primary_attendee_addressees() { |
759 | 759 | $aee = $this->_default_addressee_data; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -261,7 +261,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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; |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -270,7 +271,9 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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. |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -166,8 +167,9 @@ discard block |
||
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. |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -34,7 +34,7 @@ discard block |
||
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 |
||
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 |
||
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; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | 5 | |
6 | 6 | /** |
@@ -123,7 +123,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
3 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
4 | 4 | exit('NO direct script access allowed'); |
5 | +} |
|
5 | 6 | |
6 | 7 | /** |
7 | 8 | * Event Espresso |
@@ -276,7 +277,9 @@ discard block |
||
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 |