@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @param EE_Line_Item $line_item |
18 | 18 | * @param array $options |
19 | - * @return mixed |
|
19 | + * @return string |
|
20 | 20 | */ |
21 | 21 | public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
22 | 22 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param EE_Line_Item $line_item |
96 | 96 | * @param array $options |
97 | - * @return mixed |
|
97 | + * @return string |
|
98 | 98 | */ |
99 | 99 | private function _item_row( EE_Line_Item $line_item, $options = array() ) { |
100 | 100 | // start of row |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @param EE_Line_Item $line_item |
125 | 125 | * @param array $options |
126 | - * @return mixed |
|
126 | + * @return string |
|
127 | 127 | */ |
128 | 128 | private function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
129 | 129 | // start of row |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * |
154 | 154 | * @param EE_Line_Item $line_item |
155 | 155 | * @param array $options |
156 | - * @return mixed |
|
156 | + * @return string |
|
157 | 157 | */ |
158 | 158 | private function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
159 | 159 | // start of row |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @param EE_Line_Item $line_item |
180 | 180 | * @param string $text |
181 | 181 | * @param array $options |
182 | - * @return mixed |
|
182 | + * @return string |
|
183 | 183 | */ |
184 | 184 | private function _total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
185 | 185 | // colspan |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * _separator_row |
204 | 204 | * |
205 | 205 | * @param array $options |
206 | - * @return mixed |
|
206 | + * @return string |
|
207 | 207 | */ |
208 | 208 | private function _separator_row( $options = array() ) { |
209 | 209 | // colspan |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param array $options |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function display_line_item( EE_Line_Item $line_item, $options = array() ) { |
|
52 | + public function display_line_item(EE_Line_Item $line_item, $options = array()) { |
|
53 | 53 | |
54 | 54 | $html = ''; |
55 | 55 | // set some default options and merge with incoming |
@@ -60,43 +60,43 @@ discard block |
||
60 | 60 | 'taxes_tr_css_class' => 'admin-primary-mbox-taxes-tr', |
61 | 61 | 'total_tr_css_class' => 'admin-primary-mbox-total-tr' |
62 | 62 | ); |
63 | - $options = array_merge( $default_options, (array)$options ); |
|
63 | + $options = array_merge($default_options, (array) $options); |
|
64 | 64 | |
65 | - switch( $line_item->type() ) { |
|
65 | + switch ($line_item->type()) { |
|
66 | 66 | |
67 | 67 | case EEM_Line_Item::type_line_item: |
68 | 68 | // item row |
69 | - $html .= $this->_item_row( $line_item, $options ); |
|
69 | + $html .= $this->_item_row($line_item, $options); |
|
70 | 70 | break; |
71 | 71 | |
72 | 72 | case EEM_Line_Item::type_sub_line_item: |
73 | - $html .= $this->_sub_item_row( $line_item, $options ); |
|
73 | + $html .= $this->_sub_item_row($line_item, $options); |
|
74 | 74 | break; |
75 | 75 | |
76 | 76 | case EEM_Line_Item::type_sub_total: |
77 | - if ( $line_item->quantity() === 0 ) { |
|
77 | + if ($line_item->quantity() === 0) { |
|
78 | 78 | return $html; |
79 | 79 | } |
80 | 80 | //loop through children |
81 | 81 | $child_line_items = $line_item->children(); |
82 | 82 | //loop through children |
83 | - foreach ( $child_line_items as $child_line_item ) { |
|
83 | + foreach ($child_line_items as $child_line_item) { |
|
84 | 84 | //recursively feed children back into this method |
85 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
85 | + $html .= $this->display_line_item($child_line_item, $options); |
|
86 | 86 | } |
87 | - $html .= $this->_sub_total_row( $line_item, $options ); |
|
87 | + $html .= $this->_sub_total_row($line_item, $options); |
|
88 | 88 | break; |
89 | 89 | |
90 | 90 | case EEM_Line_Item::type_tax: |
91 | - if ( $this->_show_taxes ) { |
|
92 | - $this->_taxes_html .= $this->_tax_row( $line_item, $options ); |
|
91 | + if ($this->_show_taxes) { |
|
92 | + $this->_taxes_html .= $this->_tax_row($line_item, $options); |
|
93 | 93 | } |
94 | 94 | break; |
95 | 95 | |
96 | 96 | case EEM_Line_Item::type_tax_sub_total: |
97 | - foreach( $line_item->children() as $child_line_item ) { |
|
98 | - if ( $child_line_item->type() == EEM_Line_Item::type_tax ) { |
|
99 | - $this->display_line_item( $child_line_item, $options ); |
|
97 | + foreach ($line_item->children() as $child_line_item) { |
|
98 | + if ($child_line_item->type() == EEM_Line_Item::type_tax) { |
|
99 | + $this->display_line_item($child_line_item, $options); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | break; |
@@ -108,14 +108,14 @@ discard block |
||
108 | 108 | $children = $line_item->children(); |
109 | 109 | |
110 | 110 | // loop thru all non-tax child line items |
111 | - foreach( $children as $child_line_item ) { |
|
112 | - $html .= $this->display_line_item( $child_line_item, $options ); |
|
111 | + foreach ($children as $child_line_item) { |
|
112 | + $html .= $this->display_line_item($child_line_item, $options); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $html .= $this->_taxes_html; |
116 | - $html .= $this->_total_row( $line_item, $options ); |
|
117 | - if ( $options['use_table_wrapper'] ) { |
|
118 | - $html = $this->_table_header( $options ) . $html . $this->_table_footer( $options ); |
|
116 | + $html .= $this->_total_row($line_item, $options); |
|
117 | + if ($options['use_table_wrapper']) { |
|
118 | + $html = $this->_table_header($options).$html.$this->_table_footer($options); |
|
119 | 119 | } |
120 | 120 | break; |
121 | 121 | |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | * @param array $options |
133 | 133 | * @return string |
134 | 134 | */ |
135 | - protected function _table_header( $options ) { |
|
136 | - $html = EEH_HTML::table( '','', $options['table_css_class'] ); |
|
135 | + protected function _table_header($options) { |
|
136 | + $html = EEH_HTML::table('', '', $options['table_css_class']); |
|
137 | 137 | $html .= EEH_HTML::thead(); |
138 | 138 | $html .= EEH_HTML::tr(); |
139 | - $html .= EEH_HTML::th( __( 'Name', 'event_espresso' ), '', 'jst-left' ); |
|
140 | - $html .= EEH_HTML::th( __( 'Type', 'event_espresso'), '', 'jst-left' ); |
|
141 | - $html .= EEH_HTML::th( __( 'Amount', 'event_espresso' ), '', 'jst-cntr' ); |
|
142 | - $html .= EEH_HTML::th( __( 'Qty', 'event_espresso' ), '', 'jst-cntr' ); |
|
143 | - $html .= EEH_HTML::th( __( 'Line Total', 'event_espresso'), '', 'jst-cntr' ); |
|
139 | + $html .= EEH_HTML::th(__('Name', 'event_espresso'), '', 'jst-left'); |
|
140 | + $html .= EEH_HTML::th(__('Type', 'event_espresso'), '', 'jst-left'); |
|
141 | + $html .= EEH_HTML::th(__('Amount', 'event_espresso'), '', 'jst-cntr'); |
|
142 | + $html .= EEH_HTML::th(__('Qty', 'event_espresso'), '', 'jst-cntr'); |
|
143 | + $html .= EEH_HTML::th(__('Line Total', 'event_espresso'), '', 'jst-cntr'); |
|
144 | 144 | $html .= EEH_HTML::tbody(); |
145 | 145 | return $html; |
146 | 146 | } |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * @param array $options array of options for the table. |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - protected function _table_footer( $options ) { |
|
156 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex(); |
|
155 | + protected function _table_footer($options) { |
|
156 | + return EEH_HTML::tbodyx().EEH_HTML::tablex(); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
@@ -165,12 +165,12 @@ discard block |
||
165 | 165 | * @param array $options |
166 | 166 | * @return mixed |
167 | 167 | */ |
168 | - protected function _item_row( EE_Line_Item $line_item, $options = array() ) { |
|
168 | + protected function _item_row(EE_Line_Item $line_item, $options = array()) { |
|
169 | 169 | $line_item_related_object = $line_item->get_object(); |
170 | 170 | $parent_line_item_related_object = $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->get_object() : null; |
171 | 171 | // start of row |
172 | 172 | $row_class = $options['odd'] ? 'item odd' : 'item'; |
173 | - $html = EEH_HTML::tr( '', '', $row_class ); |
|
173 | + $html = EEH_HTML::tr('', '', $row_class); |
|
174 | 174 | |
175 | 175 | |
176 | 176 | //Name Column |
@@ -178,45 +178,45 @@ discard block |
||
178 | 178 | |
179 | 179 | //related object scope. |
180 | 180 | $parent_related_object_name = $parent_line_item_related_object instanceof EEI_Line_Item_Object ? $parent_line_item_related_object->name() : ''; |
181 | - $parent_related_object_name = empty( $parent_related_object_name ) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
181 | + $parent_related_object_name = empty($parent_related_object_name) && $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->name() : $parent_related_object_name; |
|
182 | 182 | $parent_related_object_link = $parent_line_item_related_object instanceof EEI_Admin_Links ? $parent_line_item_related_object->get_admin_details_link() : ''; |
183 | 183 | |
184 | 184 | |
185 | 185 | $name_html = $line_item_related_object instanceof EEI_Line_Item_Object ? $line_item_related_object->name() : $line_item->name(); |
186 | - $name_html = $name_link ? '<a href="' . $name_link . '">' . $name_html . '</a>' : $name_html; |
|
186 | + $name_html = $name_link ? '<a href="'.$name_link.'">'.$name_html.'</a>' : $name_html; |
|
187 | 187 | $name_html .= $line_item->is_taxable() ? ' *' : ''; |
188 | 188 | //maybe preface with icon? |
189 | - $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon() . $name_html : $name_html; |
|
190 | - $name_html = '<span class="ee-line-item-name linked">' . $name_html . '</span><br>'; |
|
191 | - $name_html .= sprintf( |
|
192 | - _x( '%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
189 | + $name_html = $line_item_related_object instanceof EEI_Has_Icon ? $line_item_related_object->get_icon().$name_html : $name_html; |
|
190 | + $name_html = '<span class="ee-line-item-name linked">'.$name_html.'</span><br>'; |
|
191 | + $name_html .= sprintf( |
|
192 | + _x('%1$sfor the %2$s: %3$s%4$s', 'eg. "for the Event: My Cool Event"', 'event_espresso'), |
|
193 | 193 | '<span class="ee-line-item-related-parent-object">', |
194 | - $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __( 'Item:', 'event_espresso' ), |
|
195 | - $parent_related_object_link ? '<a href="' . $parent_related_object_link . '">' . $parent_related_object_name . '</a>' : $parent_related_object_name, |
|
194 | + $line_item->parent() instanceof EE_Line_Item ? $line_item->parent()->OBJ_type_i18n() : __('Item:', 'event_espresso'), |
|
195 | + $parent_related_object_link ? '<a href="'.$parent_related_object_link.'">'.$parent_related_object_name.'</a>' : $parent_related_object_name, |
|
196 | 196 | '</span>' |
197 | 197 | ); |
198 | - $html .= EEH_HTML::td( $name_html, '', 'jst-left' ); |
|
198 | + $html .= EEH_HTML::td($name_html, '', 'jst-left'); |
|
199 | 199 | //Type Column |
200 | 200 | $type_html = $line_item->OBJ_type() ? $line_item->OBJ_type_i18n() : ''; |
201 | - $type_html .= $this->_get_cancellations( $line_item ); |
|
201 | + $type_html .= $this->_get_cancellations($line_item); |
|
202 | 202 | $type_html .= $line_item->OBJ_type() ? '<br />' : ''; |
203 | 203 | $code = $line_item_related_object instanceof EEI_Has_Code ? $line_item_related_object->code() : ''; |
204 | - $type_html .= ! empty( $code ) ? '<span class="ee-line-item-id">' . sprintf( __( 'Code: %s', 'event_espresso' ), $code ) . '</span>' : ''; |
|
205 | - $html .= EEH_HTML::td( $type_html, '', 'jst-left' ); |
|
204 | + $type_html .= ! empty($code) ? '<span class="ee-line-item-id">'.sprintf(__('Code: %s', 'event_espresso'), $code).'</span>' : ''; |
|
205 | + $html .= EEH_HTML::td($type_html, '', 'jst-left'); |
|
206 | 206 | |
207 | 207 | |
208 | 208 | //Amount Column |
209 | - if ( $line_item->is_percent() ) { |
|
210 | - $html .= EEH_HTML::td( $line_item->percent() . '%', '', 'jst-rght' ); |
|
209 | + if ($line_item->is_percent()) { |
|
210 | + $html .= EEH_HTML::td($line_item->percent().'%', '', 'jst-rght'); |
|
211 | 211 | } else { |
212 | - $html .= EEH_HTML::td( $line_item->unit_price_no_code(), '', 'jst-rght' ); |
|
212 | + $html .= EEH_HTML::td($line_item->unit_price_no_code(), '', 'jst-rght'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | //QTY column |
216 | - $html .= EEH_HTML::td( $line_item->quantity(), '', 'jst-rght' ); |
|
216 | + $html .= EEH_HTML::td($line_item->quantity(), '', 'jst-rght'); |
|
217 | 217 | |
218 | 218 | //total column |
219 | - $html .= EEH_HTML::td( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
219 | + $html .= EEH_HTML::td(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
220 | 220 | |
221 | 221 | //finish things off and return |
222 | 222 | $html .= EEH_HTML::trx(); |
@@ -231,12 +231,12 @@ discard block |
||
231 | 231 | * @param EE_Line_Item $line_item |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - protected function _get_cancellations( EE_Line_Item $line_item ) { |
|
234 | + protected function _get_cancellations(EE_Line_Item $line_item) { |
|
235 | 235 | $html = ''; |
236 | 236 | $cancellations = $line_item->get_cancellations(); |
237 | - $cancellation = reset( $cancellations ); |
|
237 | + $cancellation = reset($cancellations); |
|
238 | 238 | // \EEH_Debug_Tools::printr( $cancellation, '$cancellation', __FILE__, __LINE__ ); |
239 | - if ( $cancellation instanceof EE_Line_Item ) { |
|
239 | + if ($cancellation instanceof EE_Line_Item) { |
|
240 | 240 | $html .= ' <span class="ee-line-item-id">'; |
241 | 241 | $html .= sprintf( |
242 | 242 | _n( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param array $options |
262 | 262 | * @return mixed |
263 | 263 | */ |
264 | - protected function _sub_item_row( EE_Line_Item $line_item, $options = array() ) { |
|
264 | + protected function _sub_item_row(EE_Line_Item $line_item, $options = array()) { |
|
265 | 265 | //for now we're not showing sub-items |
266 | 266 | return ''; |
267 | 267 | } |
@@ -275,13 +275,13 @@ discard block |
||
275 | 275 | * @param array $options |
276 | 276 | * @return mixed |
277 | 277 | */ |
278 | - protected function _tax_row( EE_Line_Item $line_item, $options = array() ) { |
|
278 | + protected function _tax_row(EE_Line_Item $line_item, $options = array()) { |
|
279 | 279 | // start of row |
280 | - $html = EEH_HTML::tr( '', 'admin-primary-mbox-taxes-tr' ); |
|
280 | + $html = EEH_HTML::tr('', 'admin-primary-mbox-taxes-tr'); |
|
281 | 281 | // name th |
282 | - $html .= EEH_HTML::th( $line_item->name() . '(' . $line_item->get_pretty( 'LIN_percent' ) . '%)', '', 'jst-rght', '', ' colspan="4"' ); |
|
282 | + $html .= EEH_HTML::th($line_item->name().'('.$line_item->get_pretty('LIN_percent').'%)', '', 'jst-rght', '', ' colspan="4"'); |
|
283 | 283 | // total th |
284 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
284 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
285 | 285 | // end of row |
286 | 286 | $html .= EEH_HTML::trx(); |
287 | 287 | return $html; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @param array $options |
299 | 299 | * @return mixed |
300 | 300 | */ |
301 | - protected function _sub_total_row( EE_Line_Item $line_item, $text = '', $options = array() ) { |
|
301 | + protected function _sub_total_row(EE_Line_Item $line_item, $text = '', $options = array()) { |
|
302 | 302 | //currently not showing subtotal row |
303 | 303 | return ''; |
304 | 304 | } |
@@ -312,15 +312,15 @@ discard block |
||
312 | 312 | * @param array $options |
313 | 313 | * @return mixed |
314 | 314 | */ |
315 | - protected function _total_row( EE_Line_Item $line_item, $options = array() ) { |
|
315 | + protected function _total_row(EE_Line_Item $line_item, $options = array()) { |
|
316 | 316 | // start of row |
317 | - $html = EEH_HTML::tr( '', '', 'admin-primary-mbox-total-tr' ); |
|
317 | + $html = EEH_HTML::tr('', '', 'admin-primary-mbox-total-tr'); |
|
318 | 318 | // Total th label |
319 | - $total_label = sprintf( __( 'Transaction Total %s', 'event_espresso' ), '(' . EE_Registry::instance()->CFG->currency->code . ')' ); |
|
320 | - $html .= EEH_HTML::th( $total_label, '', 'jst-rght', '', ' colspan="4"' ); |
|
319 | + $total_label = sprintf(__('Transaction Total %s', 'event_espresso'), '('.EE_Registry::instance()->CFG->currency->code.')'); |
|
320 | + $html .= EEH_HTML::th($total_label, '', 'jst-rght', '', ' colspan="4"'); |
|
321 | 321 | // total th |
322 | 322 | |
323 | - $html .= EEH_HTML::th( EEH_Template::format_currency( $line_item->total(), false, false ), '', 'jst-rght' ); |
|
323 | + $html .= EEH_HTML::th(EEH_Template::format_currency($line_item->total(), false, false), '', 'jst-rght'); |
|
324 | 324 | // end of row |
325 | 325 | $html .= EEH_HTML::trx(); |
326 | 326 | return $html; |
@@ -767,7 +767,7 @@ |
||
767 | 767 | * Takes care of setting up the addressee object(s) for the primary attendee. |
768 | 768 | * |
769 | 769 | * @access protected |
770 | - * @return array of EE_Addressee objects |
|
770 | + * @return EE_Messages_Addressee[] of EE_Addressee objects |
|
771 | 771 | */ |
772 | 772 | protected function _primary_attendee_addressees() { |
773 | 773 | $aee = $this->_default_addressee_data; |
@@ -864,8 +864,8 @@ |
||
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | 866 | if ( isset( $this->_data->reg_obj ) |
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | - && $this->_single_message |
|
867 | + && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
868 | + && $this->_single_message |
|
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | * EE_Base_Class_Object |
275 | 275 | * @return mixed ( EE_Base_Class||EE_Base_Class[] ) |
276 | 276 | */ |
277 | - abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id ); |
|
277 | + abstract protected function _get_data_for_context($context, EE_Registration $registration, $id); |
|
278 | 278 | |
279 | 279 | |
280 | 280 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @deprecated 4.9.0 |
302 | 302 | * @return int |
303 | 303 | */ |
304 | - protected function _get_id_for_msg_url( $context, EE_Registration $registration ) { |
|
304 | + protected function _get_id_for_msg_url($context, EE_Registration $registration) { |
|
305 | 305 | return 0; |
306 | 306 | } |
307 | 307 | |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * sending. |
331 | 331 | * @since 4.9.0 |
332 | 332 | */ |
333 | - public function do_messenger_hooks( $messenger = null ) { |
|
333 | + public function do_messenger_hooks($messenger = null) { |
|
334 | 334 | $this->_active_messenger = $messenger; |
335 | 335 | $this->_do_messenger_hooks(); |
336 | 336 | } |
@@ -379,10 +379,10 @@ discard block |
||
379 | 379 | * @param mixed $data This sets the data property for the message type with the incoming data used for generating. |
380 | 380 | * @return string (the reference for the data handler) (will be an empty string if could not be determined). |
381 | 381 | */ |
382 | - public function get_data_handler( $data ) { |
|
382 | + public function get_data_handler($data) { |
|
383 | 383 | $this->_data = $data; |
384 | 384 | $this->_set_data_handler(); |
385 | - return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this ); |
|
385 | + return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | |
@@ -419,26 +419,26 @@ discard block |
||
419 | 419 | * @deprecated 4.9.0 Likely 4.9.10 or 4.10.0 will remove this method completely |
420 | 420 | * @return string generated url |
421 | 421 | */ |
422 | - public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) { |
|
422 | + public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) { |
|
423 | 423 | //validate context |
424 | 424 | //valid context? |
425 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
425 | + if ( ! isset($this->_contexts[$context])) { |
|
426 | 426 | throw new EE_Error( |
427 | 427 | sprintf( |
428 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
428 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
429 | 429 | $context, |
430 | - get_class( $this ) |
|
430 | + get_class($this) |
|
431 | 431 | ) |
432 | 432 | ); |
433 | 433 | } |
434 | 434 | //valid sending_messenger? |
435 | 435 | $not_valid_msgr = false; |
436 | - foreach ( $this->_with_messengers as $generating => $sendings ) { |
|
437 | - if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === false ) { |
|
436 | + foreach ($this->_with_messengers as $generating => $sendings) { |
|
437 | + if (empty($sendings) || array_search($sending_messenger, $sendings) === false) { |
|
438 | 438 | $not_valid_msgr = true; |
439 | 439 | } |
440 | 440 | } |
441 | - if ( $not_valid_msgr ) { |
|
441 | + if ($not_valid_msgr) { |
|
442 | 442 | throw new EE_Error( |
443 | 443 | sprintf( |
444 | 444 | __( |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | 'event_espresso' |
447 | 447 | ), |
448 | 448 | $sending_messenger, |
449 | - get_class( $this ) |
|
449 | + get_class($this) |
|
450 | 450 | ) |
451 | 451 | ); |
452 | 452 | } |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | $this->name, |
458 | 458 | $registration, |
459 | 459 | $this->_GRP_ID, |
460 | - $this->_get_id_for_msg_url( $context, $registration ) |
|
460 | + $this->_get_id_for_msg_url($context, $registration) |
|
461 | 461 | ); |
462 | 462 | } |
463 | 463 | |
@@ -476,26 +476,26 @@ discard block |
||
476 | 476 | * EE_Base_Class_Object |
477 | 477 | * @return mixed (EE_Base_Class||EE_Base_Class[]) |
478 | 478 | */ |
479 | - public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) { |
|
479 | + public function get_data_for_context($context, EE_Registration $registration, $id = 0) { |
|
480 | 480 | //valid context? |
481 | - if ( ! isset( $this->_contexts[ $context ] ) ) { |
|
481 | + if ( ! isset($this->_contexts[$context])) { |
|
482 | 482 | throw new EE_Error( |
483 | 483 | sprintf( |
484 | - __( 'The context %s is not a valid context for %s.', 'event_espresso' ), |
|
484 | + __('The context %s is not a valid context for %s.', 'event_espresso'), |
|
485 | 485 | $context, |
486 | - get_class( $this ) |
|
486 | + get_class($this) |
|
487 | 487 | ) |
488 | 488 | ); |
489 | 489 | } |
490 | 490 | //get data and apply global and class specific filters on it. |
491 | 491 | $data = apply_filters( |
492 | 492 | 'FHEE__EE_message_type__get_data_for_context__data', |
493 | - $this->_get_data_for_context( $context, $registration, $id ), |
|
493 | + $this->_get_data_for_context($context, $registration, $id), |
|
494 | 494 | $this |
495 | 495 | ); |
496 | - $data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this ); |
|
496 | + $data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this); |
|
497 | 497 | //if empty then something went wrong! |
498 | - if ( empty( $data ) ) { |
|
498 | + if (empty($data)) { |
|
499 | 499 | throw new EE_Error( |
500 | 500 | sprintf( |
501 | 501 | __( |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | */ |
540 | 540 | protected function _set_with_messengers() { |
541 | 541 | $this->_with_messengers = array( |
542 | - 'email' => array( 'html' ), |
|
542 | + 'email' => array('html'), |
|
543 | 543 | ); |
544 | 544 | } |
545 | 545 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | */ |
554 | 554 | public function with_messengers() { |
555 | 555 | return apply_filters( |
556 | - 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), |
|
556 | + 'FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), |
|
557 | 557 | $this->_with_messengers |
558 | 558 | ); |
559 | 559 | } |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $messengers = array() |
581 | 581 | ) { |
582 | 582 | //we can also further refine the context by action (if present). |
583 | - return $this->_get_admin_page_content( $page, $action, $extra, $messengers ); |
|
583 | + return $this->_get_admin_page_content($page, $action, $extra, $messengers); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | |
@@ -615,10 +615,10 @@ discard block |
||
615 | 615 | public function get_master_templates() { |
616 | 616 | //first class specific filter then filter that by the global filter. |
617 | 617 | $master_templates = apply_filters( |
618 | - 'FHEE__' . get_class( $this ) . '__get_master_templates', |
|
618 | + 'FHEE__'.get_class($this).'__get_master_templates', |
|
619 | 619 | $this->_master_templates |
620 | 620 | ); |
621 | - return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this ); |
|
621 | + return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -632,20 +632,20 @@ discard block |
||
632 | 632 | * @return array An array indexed by context where each context is an array of EE_Messages_Addressee objects for |
633 | 633 | * that context |
634 | 634 | */ |
635 | - public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) { |
|
635 | + public function get_addressees(EE_Messages_incoming_data $data, $context = '') { |
|
636 | 636 | //override _data |
637 | 637 | $this->_data = $data; |
638 | 638 | $addressees = array(); |
639 | 639 | //if incoming context then limit to that context |
640 | - if ( ! empty( $context ) ) { |
|
641 | - $cntxt = ! empty( $this->_contexts[ $context ] ) ? $this->_contexts[ $context ] : ''; |
|
642 | - if ( ! empty( $cntxt ) ) { |
|
640 | + if ( ! empty($context)) { |
|
641 | + $cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : ''; |
|
642 | + if ( ! empty($cntxt)) { |
|
643 | 643 | $this->_contexts = array(); |
644 | - $this->_contexts[ $context ] = $cntxt; |
|
644 | + $this->_contexts[$context] = $cntxt; |
|
645 | 645 | } |
646 | 646 | } |
647 | 647 | $this->_set_default_addressee_data(); |
648 | - if ( $this->_process_data() ) { |
|
648 | + if ($this->_process_data()) { |
|
649 | 649 | $addressees = $this->_addressees; |
650 | 650 | } |
651 | 651 | return $addressees; |
@@ -661,14 +661,14 @@ discard block |
||
661 | 661 | */ |
662 | 662 | protected function _process_data() { |
663 | 663 | //at a minimum, we NEED EE_Attendee objects. |
664 | - if ( empty( $this->_data->attendees ) ) { |
|
665 | - return false; //there's no data to process! |
|
664 | + if (empty($this->_data->attendees)) { |
|
665 | + return false; //there's no data to process! |
|
666 | 666 | } |
667 | 667 | // process addressees for each context. Child classes will have to have methods for |
668 | 668 | // each context defined to handle the processing of the data object within them |
669 | - foreach ( $this->_contexts as $context => $details ) { |
|
670 | - $xpctd_method = '_' . $context . '_addressees'; |
|
671 | - if ( ! method_exists( $this, $xpctd_method ) ) { |
|
669 | + foreach ($this->_contexts as $context => $details) { |
|
670 | + $xpctd_method = '_'.$context.'_addressees'; |
|
671 | + if ( ! method_exists($this, $xpctd_method)) { |
|
672 | 672 | throw new EE_Error( |
673 | 673 | sprintf( |
674 | 674 | __( |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | ) |
681 | 681 | ); |
682 | 682 | } |
683 | - $this->_addressees[ $context ] = call_user_func( array( $this, $xpctd_method ) ); |
|
683 | + $this->_addressees[$context] = call_user_func(array($this, $xpctd_method)); |
|
684 | 684 | } |
685 | 685 | return true; //data was processed successfully. |
686 | 686 | } |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | 'grand_total_line_item' => $this->_data->grand_total_line_item, |
703 | 703 | 'txn' => $this->_data->txn, |
704 | 704 | 'payments' => $this->_data->payments, |
705 | - 'payment' => isset( $this->_data->payment ) && $this->_data->payment instanceof EE_Payment |
|
705 | + 'payment' => isset($this->_data->payment) && $this->_data->payment instanceof EE_Payment |
|
706 | 706 | ? $this->_data->payment |
707 | 707 | : null, |
708 | 708 | 'reg_objs' => $this->_data->reg_objs, |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | 'txn_status' => $this->_data->txn_status, |
716 | 716 | 'total_ticket_count' => $this->_data->total_ticket_count, |
717 | 717 | ); |
718 | - if ( is_array( $this->_data->primary_attendee_data ) ) { |
|
718 | + if (is_array($this->_data->primary_attendee_data)) { |
|
719 | 719 | $this->_default_addressee_data = array_merge( |
720 | 720 | $this->_default_addressee_data, |
721 | 721 | $this->_data->primary_attendee_data |
@@ -759,24 +759,24 @@ discard block |
||
759 | 759 | 'messenger', |
760 | 760 | ); |
761 | 761 | $contexts = $this->get_contexts(); |
762 | - foreach ( $contexts as $context => $details ) { |
|
763 | - $this->_valid_shortcodes[ $context ] = $all_shortcodes; |
|
762 | + foreach ($contexts as $context => $details) { |
|
763 | + $this->_valid_shortcodes[$context] = $all_shortcodes; |
|
764 | 764 | //make sure non admin context does not include the event_author shortcodes |
765 | - if ( $context != 'admin' ) { |
|
766 | - if ( ( $key = array_search( 'event_author', $this->_valid_shortcodes[ $context ] ) ) !== false ) { |
|
767 | - unset( $this->_valid_shortcodes[ $context ][ $key ] ); |
|
765 | + if ($context != 'admin') { |
|
766 | + if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) { |
|
767 | + unset($this->_valid_shortcodes[$context][$key]); |
|
768 | 768 | } |
769 | 769 | } |
770 | 770 | } |
771 | 771 | // make sure admin context does not include the recipient_details shortcodes |
772 | 772 | // IF we have admin context hooked in message types might not have that context. |
773 | - if ( ! empty( $this->_valid_shortcodes['admin'] ) ) { |
|
774 | - if ( ( $key = array_search( 'recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
775 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
773 | + if ( ! empty($this->_valid_shortcodes['admin'])) { |
|
774 | + if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) { |
|
775 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
776 | 776 | } |
777 | 777 | //make sure admin context does not include the recipient_details shortcodes |
778 | - if ( ( $key = array_search( 'recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false ) { |
|
779 | - unset( $this->_valid_shortcodes['admin'][ $key ] ); |
|
778 | + if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) { |
|
779 | + unset($this->_valid_shortcodes['admin'][$key]); |
|
780 | 780 | } |
781 | 781 | } |
782 | 782 | } |
@@ -789,9 +789,9 @@ discard block |
||
789 | 789 | * @param array $new_config array of valid shortcodes (by context) |
790 | 790 | * @return void sets valid_shortcodes property |
791 | 791 | */ |
792 | - public function reset_valid_shortcodes_config( $new_config ) { |
|
793 | - foreach ( $new_config as $context => $shortcodes ) { |
|
794 | - $this->_valid_shortcodes[ $context ] = $shortcodes; |
|
792 | + public function reset_valid_shortcodes_config($new_config) { |
|
793 | + foreach ($new_config as $context => $shortcodes) { |
|
794 | + $this->_valid_shortcodes[$context] = $shortcodes; |
|
795 | 795 | } |
796 | 796 | } |
797 | 797 | |
@@ -808,13 +808,13 @@ discard block |
||
808 | 808 | $addressees = array(); |
809 | 809 | // first we need to get the event admin user id for all the events |
810 | 810 | // and setup an addressee object for each unique admin user. |
811 | - foreach ( $this->_data->events as $line_ref => $event ) { |
|
812 | - $admin_id = $this->_get_event_admin_id( $event['ID'] ); |
|
811 | + foreach ($this->_data->events as $line_ref => $event) { |
|
812 | + $admin_id = $this->_get_event_admin_id($event['ID']); |
|
813 | 813 | //make sure we are just including the events that belong to this admin! |
814 | - $admin_events[ $admin_id ][ $line_ref ] = $event; |
|
814 | + $admin_events[$admin_id][$line_ref] = $event; |
|
815 | 815 | } |
816 | 816 | //k now we can loop through the event_admins and setup the addressee data. |
817 | - foreach ( $admin_events as $admin_id => $event_details ) { |
|
817 | + foreach ($admin_events as $admin_id => $event_details) { |
|
818 | 818 | $aee = array( |
819 | 819 | 'user_id' => $admin_id, |
820 | 820 | 'events' => $event_details, |
@@ -822,8 +822,8 @@ discard block |
||
822 | 822 | 'recipient_id' => $admin_id, |
823 | 823 | 'recipient_type' => 'WP_User', |
824 | 824 | ); |
825 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
826 | - $addressees[] = new EE_Messages_Addressee( $aee ); |
|
825 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
826 | + $addressees[] = new EE_Messages_Addressee($aee); |
|
827 | 827 | } |
828 | 828 | return $addressees; |
829 | 829 | } |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | $aee['recipient_id'] = $aee['primary_att_obj'] instanceof EE_Attendee ? $aee['primary_att_obj']->ID() : 0; |
844 | 844 | $aee['recipient_type'] = 'Attendee'; |
845 | 845 | //great now we can instantiate the $addressee object and return (as an array); |
846 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
846 | + $add[] = new EE_Messages_Addressee($aee); |
|
847 | 847 | return $add; |
848 | 848 | } |
849 | 849 | |
@@ -860,25 +860,25 @@ discard block |
||
860 | 860 | //we just have to loop through the attendees. We'll also set the attached events for each attendee. |
861 | 861 | //use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we? |
862 | 862 | $already_processed = array(); |
863 | - foreach ( $this->_data->attendees as $att_id => $details ) { |
|
863 | + foreach ($this->_data->attendees as $att_id => $details) { |
|
864 | 864 | //set the attendee array to blank on each loop; |
865 | 865 | $aee = array(); |
866 | - if ( isset( $this->_data->reg_obj ) |
|
867 | - && ( $this->_data->reg_obj->attendee_ID() != $att_id ) |
|
866 | + if (isset($this->_data->reg_obj) |
|
867 | + && ($this->_data->reg_obj->attendee_ID() != $att_id) |
|
868 | 868 | && $this->_single_message |
869 | 869 | ) { |
870 | 870 | continue; |
871 | 871 | } |
872 | 872 | // is $this->_regs_for_sending present? |
873 | 873 | // If so, let's make sure we ONLY generate addressee for registrations in that array. |
874 | - if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) { |
|
875 | - $regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] ); |
|
876 | - if ( empty( $regs_allowed ) ) { |
|
874 | + if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) { |
|
875 | + $regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']); |
|
876 | + if (empty($regs_allowed)) { |
|
877 | 877 | continue; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | if ( |
881 | - in_array( $details['attendee_email'], $already_processed ) |
|
881 | + in_array($details['attendee_email'], $already_processed) |
|
882 | 882 | && apply_filters( |
883 | 883 | 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', |
884 | 884 | true, |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | continue; |
890 | 890 | } |
891 | 891 | $already_processed[] = $details['attendee_email']; |
892 | - foreach ( $details as $item => $value ) { |
|
893 | - $aee[ $item ] = $value; |
|
894 | - if ( $item == 'line_ref' ) { |
|
895 | - foreach ( $value as $event_id ) { |
|
896 | - $aee['events'][ $event_id ] = $this->_data->events[ $event_id ]; |
|
892 | + foreach ($details as $item => $value) { |
|
893 | + $aee[$item] = $value; |
|
894 | + if ($item == 'line_ref') { |
|
895 | + foreach ($value as $event_id) { |
|
896 | + $aee['events'][$event_id] = $this->_data->events[$event_id]; |
|
897 | 897 | } |
898 | 898 | } |
899 | - if ( $item == 'attendee_email' ) { |
|
899 | + if ($item == 'attendee_email') { |
|
900 | 900 | $aee['attendee_email'] = $value; |
901 | 901 | } |
902 | 902 | /*if ( $item == 'registration_id' ) { |
@@ -905,13 +905,13 @@ discard block |
||
905 | 905 | } |
906 | 906 | // note the FIRST reg object in this array is the one |
907 | 907 | // we'll use for this attendee as the primary registration for this attendee. |
908 | - $aee['reg_obj'] = reset( $this->_data->attendees[ $att_id ]['reg_objs'] ); |
|
908 | + $aee['reg_obj'] = reset($this->_data->attendees[$att_id]['reg_objs']); |
|
909 | 909 | $aee['attendees'] = $this->_data->attendees; |
910 | 910 | $aee['recipient_id'] = $att_id; |
911 | 911 | $aee['recipient_type'] = 'Attendee'; |
912 | 912 | //merge in the primary attendee data |
913 | - $aee = array_merge( $this->_default_addressee_data, $aee ); |
|
914 | - $add[] = new EE_Messages_Addressee( $aee ); |
|
913 | + $aee = array_merge($this->_default_addressee_data, $aee); |
|
914 | + $add[] = new EE_Messages_Addressee($aee); |
|
915 | 915 | } |
916 | 916 | return $add; |
917 | 917 | } |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * @param $event_id |
923 | 923 | * @return int |
924 | 924 | */ |
925 | - protected function _get_event_admin_id( $event_id ) { |
|
926 | - $event = EEM_Event::instance()->get_one_by_ID( $event_id ); |
|
925 | + protected function _get_event_admin_id($event_id) { |
|
926 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
927 | 927 | return $event instanceof EE_Event ? $event->wp_user() : 0; |
928 | 928 | } |
929 | 929 |
@@ -410,7 +410,7 @@ |
||
410 | 410 | /** |
411 | 411 | * This simply loops through all active messengers and takes care of setting up the |
412 | 412 | * EE_Message_To_Generate objects. |
413 | - * @param $message_type |
|
413 | + * @param string $message_type |
|
414 | 414 | * @param $data |
415 | 415 | * |
416 | 416 | * @return EE_Message_To_Generate[] |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @param EE_Message_Resource_Manager $message_resource_manager |
37 | 37 | */ |
38 | - public function __construct( EE_Message_Resource_Manager $message_resource_manager ) { |
|
38 | + public function __construct(EE_Message_Resource_Manager $message_resource_manager) { |
|
39 | 39 | $this->_message_resource_manager = $message_resource_manager; |
40 | 40 | $this->_init_queue_and_generator(); |
41 | 41 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * - $_generator = holds the messages generator |
51 | 51 | */ |
52 | 52 | protected function _init_queue_and_generator() { |
53 | - $this->_generator = EE_Registry::factory( 'EE_Messages_Generator' ); |
|
53 | + $this->_generator = EE_Registry::factory('EE_Messages_Generator'); |
|
54 | 54 | $this->_queue = $this->_generator->generation_queue(); |
55 | 55 | } |
56 | 56 | |
@@ -75,31 +75,31 @@ discard block |
||
75 | 75 | * @param EE_Messages_Queue $queue_to_process |
76 | 76 | * @return bool true for success false for error. |
77 | 77 | */ |
78 | - public function process_immediately_from_queue( EE_Messages_Queue $queue_to_process ) { |
|
78 | + public function process_immediately_from_queue(EE_Messages_Queue $queue_to_process) { |
|
79 | 79 | $success = false; |
80 | 80 | $messages_to_send = array(); |
81 | 81 | $messages_to_generate = array(); |
82 | 82 | //loop through and setup the various messages from the queue so we know what is being processed |
83 | 83 | $queue_to_process->get_message_repository()->rewind(); |
84 | - foreach ( $queue_to_process->get_message_repository() as $message ) { |
|
85 | - if ( $message->STS_ID() === EEM_Message::status_incomplete ) { |
|
84 | + foreach ($queue_to_process->get_message_repository() as $message) { |
|
85 | + if ($message->STS_ID() === EEM_Message::status_incomplete) { |
|
86 | 86 | $messages_to_generate[] = $message; |
87 | 87 | continue; |
88 | 88 | } |
89 | 89 | |
90 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) { |
|
90 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) { |
|
91 | 91 | $messages_to_send[] = $message; |
92 | 92 | continue; |
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | 96 | //do generation/sends |
97 | - if ( $messages_to_generate ) { |
|
98 | - $success = $this->batch_generate_from_queue( $messages_to_generate, true ); |
|
97 | + if ($messages_to_generate) { |
|
98 | + $success = $this->batch_generate_from_queue($messages_to_generate, true); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( $messages_to_send ) { |
|
102 | - $sent = $this->batch_send_from_queue( $messages_to_send, true ); |
|
101 | + if ($messages_to_send) { |
|
102 | + $sent = $this->batch_send_from_queue($messages_to_send, true); |
|
103 | 103 | //if there was messages to generate and it failed, then we override any success value for the sending process |
104 | 104 | //otherwise we just use the return from batch send. The intent is that there is a simple response for success/fail. |
105 | 105 | //Either everything was successful or we consider it a fail. To be clear, this is a limitation of doing |
@@ -119,13 +119,13 @@ discard block |
||
119 | 119 | * @return bool|EE_Messages_Queue return false if nothing generated. This returns a new EE_Message_Queue with |
120 | 120 | * generated messages. |
121 | 121 | */ |
122 | - public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) { |
|
123 | - if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) { |
|
122 | + public function batch_generate_from_queue($messages = array(), $clear_queue = false) { |
|
123 | + if ($this->_build_queue_for_generation($messages, $clear_queue)) { |
|
124 | 124 | $new_queue = $this->_generator->generate(); |
125 | - if ( $new_queue instanceof EE_Messages_Queue ) { |
|
125 | + if ($new_queue instanceof EE_Messages_Queue) { |
|
126 | 126 | //unlock queue |
127 | 127 | $this->_queue->unlock_queue(); |
128 | - $new_queue->initiate_request_by_priority( 'send' ); |
|
128 | + $new_queue->initiate_request_by_priority('send'); |
|
129 | 129 | return $new_queue; |
130 | 130 | } |
131 | 131 | } |
@@ -146,24 +146,24 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return bool true means queue prepped, false means there was a lock so no generation please. |
148 | 148 | */ |
149 | - protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) { |
|
149 | + protected function _build_queue_for_generation($messages = array(), $clear_queue = false) { |
|
150 | 150 | |
151 | - if ( $clear_queue ) { |
|
151 | + if ($clear_queue) { |
|
152 | 152 | $this->_init_queue_and_generator(); |
153 | 153 | } |
154 | 154 | |
155 | - if ( $messages ) { |
|
155 | + if ($messages) { |
|
156 | 156 | //if generation is locked then get out now because that means processing is already happening. |
157 | - if ( $this->_queue->is_locked() ) { |
|
157 | + if ($this->_queue->is_locked()) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $this->_queue->lock_queue(); |
162 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
163 | - foreach ( $messages as $message ) { |
|
164 | - if ( $message instanceof EE_Message ) { |
|
162 | + $messages = is_array($messages) ? $messages : array($messages); |
|
163 | + foreach ($messages as $message) { |
|
164 | + if ($message instanceof EE_Message) { |
|
165 | 165 | $data = $message->all_extra_meta_array(); |
166 | - $this->_queue->add( $message, $data ); |
|
166 | + $this->_queue->add($message, $data); |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | return true; |
@@ -181,22 +181,22 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @return bool true means queue prepped, false means there was a lock so no queue prepped. |
183 | 183 | */ |
184 | - protected function _build_queue_for_sending( $messages, $clear_queue = false ) { |
|
184 | + protected function _build_queue_for_sending($messages, $clear_queue = false) { |
|
185 | 185 | //if sending is locked then get out now because that means processing is already happening. |
186 | - if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) { |
|
186 | + if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
190 | - $this->_queue->lock_queue( EE_Messages_Queue::action_sending ); |
|
190 | + $this->_queue->lock_queue(EE_Messages_Queue::action_sending); |
|
191 | 191 | |
192 | - if ( $clear_queue ) { |
|
192 | + if ($clear_queue) { |
|
193 | 193 | $this->_init_queue_and_generator(); |
194 | 194 | } |
195 | 195 | |
196 | - $messages = is_array( $messages ) ? $messages : array( $messages ); |
|
196 | + $messages = is_array($messages) ? $messages : array($messages); |
|
197 | 197 | |
198 | - foreach ( $messages as $message ) { |
|
199 | - $this->_queue->add( $message ); |
|
198 | + foreach ($messages as $message) { |
|
199 | + $this->_queue->add($message); |
|
200 | 200 | } |
201 | 201 | return true; |
202 | 202 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return EE_Messages_Queue |
214 | 214 | */ |
215 | - public function batch_send_from_queue( $messages = array(), $clear_queue = false ) { |
|
215 | + public function batch_send_from_queue($messages = array(), $clear_queue = false) { |
|
216 | 216 | |
217 | - if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) { |
|
217 | + if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) { |
|
218 | 218 | $this->_queue->execute(); |
219 | - $this->_queue->unlock_queue( EE_Messages_Queue::action_sending ); |
|
219 | + $this->_queue->unlock_queue(EE_Messages_Queue::action_sending); |
|
220 | 220 | } else { |
221 | 221 | //get messages to send and execute. |
222 | 222 | $this->_queue->get_to_send_batch_and_send(); |
@@ -239,10 +239,10 @@ discard block |
||
239 | 239 | * @param EE_Message_To_Generate[] $messages_to_generate |
240 | 240 | * @return EE_Messages_Queue |
241 | 241 | */ |
242 | - public function generate_and_return( $messages_to_generate ) { |
|
242 | + public function generate_and_return($messages_to_generate) { |
|
243 | 243 | $this->_init_queue_and_generator(); |
244 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
245 | - return $this->_generator->generate( false ); |
|
244 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
245 | + return $this->_generator->generate(false); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * @param bool $persist Indicate whether to instruct the generator to persist the generated queue (true) or not (false). |
254 | 254 | * @return EE_Messages_Queue |
255 | 255 | */ |
256 | - public function generate_queue( $persist = true ) { |
|
257 | - return $this->_generator->generate( $persist ); |
|
256 | + public function generate_queue($persist = true) { |
|
257 | + return $this->_generator->generate($persist); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | * @param bool $test_send Whether this item is for a test send or not. |
268 | 268 | * @return EE_Messages_Queue |
269 | 269 | */ |
270 | - public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
271 | - if ( $message_to_generate->valid() ) { |
|
272 | - $this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send ); |
|
270 | + public function queue_for_generation(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
271 | + if ($message_to_generate->valid()) { |
|
272 | + $this->_generator->create_and_add_message_to_queue($message_to_generate, $test_send); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | * |
286 | 286 | * @param EE_Message_To_Generate[] $messages_to_generate |
287 | 287 | */ |
288 | - public function batch_queue_for_generation_and_persist( $messages_to_generate ) { |
|
288 | + public function batch_queue_for_generation_and_persist($messages_to_generate) { |
|
289 | 289 | $this->_init_queue_and_generator(); |
290 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
290 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
291 | 291 | $this->_queue->save(); |
292 | 292 | } |
293 | 293 | |
@@ -303,9 +303,9 @@ discard block |
||
303 | 303 | * |
304 | 304 | * @param EE_Message_To_Generate[] $messages_to_generate |
305 | 305 | */ |
306 | - public function batch_queue_for_generation_no_persist( $messages_to_generate ) { |
|
306 | + public function batch_queue_for_generation_no_persist($messages_to_generate) { |
|
307 | 307 | $this->_init_queue_and_generator(); |
308 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
308 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | |
@@ -317,15 +317,15 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @param EE_Message_To_Generate[] $messages_to_generate |
319 | 319 | */ |
320 | - protected function _queue_for_generation_loop( $messages_to_generate ) { |
|
320 | + protected function _queue_for_generation_loop($messages_to_generate) { |
|
321 | 321 | //make sure is in an array. |
322 | - if ( ! is_array( $messages_to_generate ) ) { |
|
323 | - $messages_to_generate = array( $messages_to_generate ); |
|
322 | + if ( ! is_array($messages_to_generate)) { |
|
323 | + $messages_to_generate = array($messages_to_generate); |
|
324 | 324 | } |
325 | 325 | |
326 | - foreach ( $messages_to_generate as $message_to_generate ) { |
|
327 | - if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) { |
|
328 | - $this->queue_for_generation( $message_to_generate ); |
|
326 | + foreach ($messages_to_generate as $message_to_generate) { |
|
327 | + if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) { |
|
328 | + $this->queue_for_generation($message_to_generate); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | } |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | * @param EE_Message_To_Generate[] |
341 | 341 | * @return EE_Messages_Queue |
342 | 342 | */ |
343 | - public function generate_and_queue_for_sending( $messages_to_generate ) { |
|
343 | + public function generate_and_queue_for_sending($messages_to_generate) { |
|
344 | 344 | $this->_init_queue_and_generator(); |
345 | - $this->_queue_for_generation_loop( $messages_to_generate ); |
|
346 | - return $this->_generator->generate( true ); |
|
345 | + $this->_queue_for_generation_loop($messages_to_generate); |
|
346 | + return $this->_generator->generate(true); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @param bool $test_send Whether this is a test send or not. |
358 | 358 | * @return EE_Messages_Queue | bool false if unable to generate otherwise the generated queue. |
359 | 359 | */ |
360 | - public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) { |
|
361 | - if ( ! $message_to_generate->valid() ) { |
|
360 | + public function generate_for_preview(EE_Message_To_Generate $message_to_generate, $test_send = false) { |
|
361 | + if ( ! $message_to_generate->valid()) { |
|
362 | 362 | EE_Error::add_error( |
363 | - __( 'Unable to generate preview because of invalid data', 'event_espresso' ), |
|
363 | + __('Unable to generate preview because of invalid data', 'event_espresso'), |
|
364 | 364 | __FILE__, |
365 | 365 | __FUNCTION__, |
366 | 366 | __LINE__ |
@@ -368,14 +368,14 @@ discard block |
||
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | //just make sure preview is set on the $message_to_generate (in case client forgot) |
371 | - $message_to_generate->set_preview( true ); |
|
371 | + $message_to_generate->set_preview(true); |
|
372 | 372 | $this->_init_queue_and_generator(); |
373 | - $this->queue_for_generation( $message_to_generate, $test_send ); |
|
374 | - $generated_queue = $this->_generator->generate( false ); |
|
375 | - if ( $generated_queue->execute( false ) ) { |
|
373 | + $this->queue_for_generation($message_to_generate, $test_send); |
|
374 | + $generated_queue = $this->_generator->generate(false); |
|
375 | + if ($generated_queue->execute(false)) { |
|
376 | 376 | //the first queue item should be the preview |
377 | 377 | $generated_queue->get_message_repository()->rewind(); |
378 | - if ( ! $generated_queue->get_message_repository()->valid() ) { |
|
378 | + if ( ! $generated_queue->get_message_repository()->valid()) { |
|
379 | 379 | return $generated_queue; |
380 | 380 | } |
381 | 381 | return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue; |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | * @param EE_Message_To_Generate $message_to_generate |
393 | 393 | * @return bool true or false for success. |
394 | 394 | */ |
395 | - public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) { |
|
396 | - if ( ! $message_to_generate->valid() ) { |
|
395 | + public function queue_for_sending(EE_Message_To_Generate $message_to_generate) { |
|
396 | + if ( ! $message_to_generate->valid()) { |
|
397 | 397 | return false; |
398 | 398 | } |
399 | 399 | $this->_init_queue_and_generator(); |
400 | 400 | $message = $message_to_generate->get_EE_Message(); |
401 | - $this->_queue->add( $message ); |
|
402 | - if ( $message->send_now() ) { |
|
403 | - $this->_queue->execute( false ); |
|
401 | + $this->_queue->add($message); |
|
402 | + if ($message->send_now()) { |
|
403 | + $this->_queue->execute(false); |
|
404 | 404 | } else { |
405 | 405 | $this->_queue->save(); |
406 | 406 | } |
@@ -413,12 +413,12 @@ discard block |
||
413 | 413 | * @param EE_Message_To_Generate $message_to_generate |
414 | 414 | * @return EE_Messages_Queue | null |
415 | 415 | */ |
416 | - public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) { |
|
417 | - if ( ! $message_to_generate->valid() ) { |
|
416 | + public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) { |
|
417 | + if ( ! $message_to_generate->valid()) { |
|
418 | 418 | return null; |
419 | 419 | } |
420 | 420 | // is there supposed to be a sending messenger for this message? |
421 | - if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) { |
|
421 | + if ($message_to_generate instanceof EEI_Has_Sending_Messenger) { |
|
422 | 422 | // make sure it's valid, but if it's not, |
423 | 423 | // then set the value of $sending_messenger to an EE_Error object |
424 | 424 | // so that downstream code can easily see that things went wrong. |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | $sending_messenger = null; |
435 | 435 | } |
436 | 436 | |
437 | - if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) { |
|
437 | + if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) { |
|
438 | 438 | $this->_init_queue_and_generator(); |
439 | - $this->_queue->add( $message_to_generate->get_EE_Message() ); |
|
440 | - $this->_queue->execute( false, $sending_messenger ); |
|
439 | + $this->_queue->add($message_to_generate->get_EE_Message()); |
|
440 | + $this->_queue->execute(false, $sending_messenger); |
|
441 | 441 | return $this->_queue; |
442 | - } elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) { |
|
443 | - $generated_queue = $this->generate_and_return( array( $message_to_generate ) ); |
|
444 | - $generated_queue->execute( false, $sending_messenger ); |
|
442 | + } elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) { |
|
443 | + $generated_queue = $this->generate_and_return(array($message_to_generate)); |
|
444 | + $generated_queue->execute(false, $sending_messenger); |
|
445 | 445 | return $generated_queue; |
446 | 446 | } |
447 | 447 | return null; |
@@ -458,13 +458,13 @@ discard block |
||
458 | 458 | * @param mixed $data The data being used for generation. |
459 | 459 | * @param bool $persist Whether to persist the queued messages to the db or not. |
460 | 460 | */ |
461 | - public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) { |
|
462 | - $messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data ); |
|
463 | - if ( $persist ) { |
|
464 | - $this->batch_queue_for_generation_and_persist( $messages_to_generate ); |
|
461 | + public function generate_for_all_active_messengers($message_type, $data, $persist = true) { |
|
462 | + $messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data); |
|
463 | + if ($persist) { |
|
464 | + $this->batch_queue_for_generation_and_persist($messages_to_generate); |
|
465 | 465 | $this->_queue->initiate_request_by_priority(); |
466 | 466 | } else { |
467 | - $this->batch_queue_for_generation_no_persist( $messages_to_generate ); |
|
467 | + $this->batch_queue_for_generation_no_persist($messages_to_generate); |
|
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
@@ -479,11 +479,11 @@ discard block |
||
479 | 479 | * |
480 | 480 | * @return EE_Message_To_Generate[] |
481 | 481 | */ |
482 | - public function setup_mtgs_for_all_active_messengers( $message_type, $data ) { |
|
482 | + public function setup_mtgs_for_all_active_messengers($message_type, $data) { |
|
483 | 483 | $messages_to_generate = array(); |
484 | - foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object ) { |
|
485 | - $message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data ); |
|
486 | - if ( $message_to_generate->valid() ) { |
|
484 | + foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) { |
|
485 | + $message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data); |
|
486 | + if ($message_to_generate->valid()) { |
|
487 | 487 | $messages_to_generate[] = $message_to_generate; |
488 | 488 | } |
489 | 489 | } |
@@ -498,29 +498,29 @@ discard block |
||
498 | 498 | * and send. |
499 | 499 | * @param array $message_ids |
500 | 500 | */ |
501 | - public function setup_messages_from_ids_and_send( $message_ids ) { |
|
501 | + public function setup_messages_from_ids_and_send($message_ids) { |
|
502 | 502 | $this->_init_queue_and_generator(); |
503 | - $messages = EEM_Message::instance()->get_all( array( |
|
503 | + $messages = EEM_Message::instance()->get_all(array( |
|
504 | 504 | array( |
505 | - 'MSG_ID' => array( 'IN', $message_ids ), |
|
505 | + 'MSG_ID' => array('IN', $message_ids), |
|
506 | 506 | 'STS_ID' => array( |
507 | 507 | 'IN', |
508 | 508 | array_merge( |
509 | 509 | EEM_Message::instance()->stati_indicating_sent(), |
510 | - array( EEM_Message::status_retry ) |
|
510 | + array(EEM_Message::status_retry) |
|
511 | 511 | ), |
512 | 512 | ), |
513 | 513 | ), |
514 | 514 | )); |
515 | 515 | //set the Messages to resend. |
516 | - foreach ( $messages as $message ) { |
|
517 | - if ( $message instanceof EE_Message ) { |
|
518 | - $message->set_STS_ID( EEM_Message::status_resend ); |
|
519 | - $this->_queue->add( $message ); |
|
516 | + foreach ($messages as $message) { |
|
517 | + if ($message instanceof EE_Message) { |
|
518 | + $message->set_STS_ID(EEM_Message::status_resend); |
|
519 | + $this->_queue->add($message); |
|
520 | 520 | } |
521 | 521 | } |
522 | 522 | |
523 | - $this->_queue->initiate_request_by_priority( 'send' ); |
|
523 | + $this->_queue->initiate_request_by_priority('send'); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | |
@@ -534,23 +534,23 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @return EE_Message_To_Generate[] |
536 | 536 | */ |
537 | - public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) { |
|
538 | - EE_Registry::instance()->load_core( 'Request_Handler' ); |
|
539 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
537 | + public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') { |
|
538 | + EE_Registry::instance()->load_core('Request_Handler'); |
|
539 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
540 | 540 | $regs_to_send = array(); |
541 | - $regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key ); |
|
542 | - if ( empty( $regIDs ) ) { |
|
543 | - EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
541 | + $regIDs = EE_Registry::instance()->REQ->get($registration_ids_key); |
|
542 | + if (empty($regIDs)) { |
|
543 | + EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
544 | 544 | return false; |
545 | 545 | } |
546 | 546 | |
547 | 547 | //make sure is an array |
548 | - $regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs ); |
|
548 | + $regIDs = is_array($regIDs) ? $regIDs : array($regIDs); |
|
549 | 549 | |
550 | - foreach( $regIDs as $regID ) { |
|
551 | - $reg = EEM_Registration::instance()->get_one_by_ID( $regID ); |
|
552 | - if ( ! $reg instanceof EE_Registration ) { |
|
553 | - EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) ); |
|
550 | + foreach ($regIDs as $regID) { |
|
551 | + $reg = EEM_Registration::instance()->get_one_by_ID($regID); |
|
552 | + if ( ! $reg instanceof EE_Registration) { |
|
553 | + EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID)); |
|
554 | 554 | return false; |
555 | 555 | } |
556 | 556 | $regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg; |
@@ -558,13 +558,13 @@ discard block |
||
558 | 558 | |
559 | 559 | $messages_to_generate = array(); |
560 | 560 | |
561 | - foreach ( $regs_to_send as $status_group ) { |
|
562 | - foreach ( $status_group as $status_id => $registrations ) { |
|
561 | + foreach ($regs_to_send as $status_group) { |
|
562 | + foreach ($status_group as $status_id => $registrations) { |
|
563 | 563 | $messages_to_generate = array_merge( |
564 | 564 | $messages_to_generate, |
565 | 565 | $this->setup_mtgs_for_all_active_messengers( |
566 | - EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ), |
|
567 | - array( $registrations, $status_id ) |
|
566 | + EEH_MSG_Template::convert_reg_status_to_message_type($status_id), |
|
567 | + array($registrations, $status_id) |
|
568 | 568 | ) |
569 | 569 | ); |
570 | 570 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | 0 => array( |
34 | 34 | 'content_id' => 'attendee-column-tip', |
35 | 35 | 'target' => '.column-attendees .dashicons-groups', |
36 | - 'content' => sprintf( __('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence') ), |
|
36 | + 'content' => sprintf(__('%s Registrations', 'event_espresso'), EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')), |
|
37 | 37 | 'options' => array( |
38 | 38 | 'position' => array( |
39 | 39 | 'my' => 'bottom left', |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param EE_Datetime constant $status What status is set (by class) |
125 | 125 | * @return string The status legend with the related status highlighted |
126 | 126 | */ |
127 | - private function _event_status_legend( $status ) { |
|
127 | + private function _event_status_legend($status) { |
|
128 | 128 | |
129 | 129 | $status_array = array( |
130 | 130 | 'active_status' => EE_Datetime::active, |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | 'inactive_status' => EE_Datetime::inactive |
137 | 137 | ); |
138 | 138 | |
139 | - return EEH_Template::status_legend( $status_array, $status ); |
|
139 | + return EEH_Template::status_legend($status_array, $status); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | } |
143 | 143 | \ No newline at end of file |
@@ -6,8 +6,9 @@ |
||
6 | 6 | * @package Event Espresso |
7 | 7 | * @subpackage messages |
8 | 8 | */ |
9 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
9 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
10 | 10 | exit('NO direct script access allowed'); |
11 | +} |
|
11 | 12 | |
12 | 13 | /** |
13 | 14 | * |
@@ -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 | /** |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | |
42 | 42 | |
43 | 43 | protected function _setup_data() { |
44 | - $this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE); |
|
45 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE ); |
|
44 | + $this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE); |
|
45 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -51,21 +51,21 @@ discard block |
||
51 | 51 | |
52 | 52 | protected function _set_properties() { |
53 | 53 | $this->_wp_list_args = array( |
54 | - 'singular' => __('Message Template Group', 'event_espresso' ), |
|
55 | - 'plural' => __('Message Template', 'event_espresso' ), |
|
54 | + 'singular' => __('Message Template Group', 'event_espresso'), |
|
55 | + 'plural' => __('Message Template', 'event_espresso'), |
|
56 | 56 | 'ajax' => TRUE, //for now, |
57 | 57 | 'screen' => $this->get_admin_page()->get_current_screen()->id |
58 | 58 | ); |
59 | 59 | $this->_columns = array( |
60 | 60 | //'cb' => '<input type="checkbox" />', //no deleting default (global) templates! |
61 | 61 | 'message_type' => __('Message Type', 'event_espresso'), |
62 | - 'messenger' => __( 'Messenger', 'event_espresso'), |
|
63 | - 'description' => __( 'Description', 'event_espresso' ), |
|
62 | + 'messenger' => __('Messenger', 'event_espresso'), |
|
63 | + 'description' => __('Description', 'event_espresso'), |
|
64 | 64 | //'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place. |
65 | 65 | ); |
66 | 66 | |
67 | 67 | $this->_sortable_columns = array( |
68 | - 'messenger' => array( 'MTP_messenger' => TRUE ), |
|
68 | + 'messenger' => array('MTP_messenger' => TRUE), |
|
69 | 69 | //'message_type' => array( 'MTP_message_type' => FALSE ) |
70 | 70 | ); |
71 | 71 | |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function single_row( $item ) { |
|
87 | + public function single_row($item) { |
|
88 | 88 | $message_type = $item->message_type_obj(); |
89 | 89 | $messenger = $item->messenger_obj(); |
90 | 90 | |
91 | - if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) { |
|
91 | + if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) { |
|
92 | 92 | echo ''; |
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | - parent::single_row( $item ); |
|
96 | + parent::single_row($item); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | ); |
112 | 112 | |
113 | 113 | //set filters to select inputs if they aren't empty |
114 | - foreach ( $select_inputs as $select_input ) { |
|
115 | - if ( $select_input ) { |
|
114 | + foreach ($select_inputs as $select_input) { |
|
115 | + if ($select_input) { |
|
116 | 116 | $filters[] = $select_input; |
117 | 117 | } |
118 | 118 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | * we're just removing the search box for message templates, not needed. |
124 | 124 | * @return string (empty); |
125 | 125 | */ |
126 | - function search_box( $text, $input_id ) { |
|
126 | + function search_box($text, $input_id) { |
|
127 | 127 | return ''; |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | protected function _add_view_counts() { |
132 | - foreach ( $this->_views as $view => $args ) { |
|
133 | - $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE ); |
|
132 | + foreach ($this->_views as $view => $args) { |
|
133 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
137 | 137 | |
138 | 138 | |
139 | - public function column_cb( $item ) { |
|
139 | + public function column_cb($item) { |
|
140 | 140 | return ''; |
141 | 141 | } |
142 | 142 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | |
145 | 145 | |
146 | 146 | |
147 | - function column_description( $item ) { |
|
148 | - return '<p>' . $item->message_type_obj()->description . '</p>'; |
|
147 | + function column_description($item) { |
|
148 | + return '<p>'.$item->message_type_obj()->description.'</p>'; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -160,27 +160,27 @@ discard block |
||
160 | 160 | $actions = array(); |
161 | 161 | |
162 | 162 | // edit link but only if item isn't trashed. |
163 | - if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) { |
|
164 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL ); |
|
165 | - $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>'; |
|
163 | + if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) { |
|
164 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL); |
|
165 | + $actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | - $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] ); |
|
168 | + $name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']); |
|
169 | 169 | |
170 | 170 | //we want to display the contexts in here so we need to set them up |
171 | 171 | $c_label = $item->context_label(); |
172 | 172 | $c_configs = $item->contexts_config(); |
173 | 173 | $ctxt = array(); |
174 | 174 | $context_templates = $item->context_templates(); |
175 | - foreach ( $context_templates as $context => $template_fields ) { |
|
176 | - $mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
177 | - $inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : ''; |
|
175 | + foreach ($context_templates as $context => $template_fields) { |
|
176 | + $mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL; |
|
177 | + $inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : ''; |
|
178 | 178 | $context_title = ucwords($c_configs[$context]['label']); |
179 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL ); |
|
180 | - $ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title; |
|
179 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL); |
|
180 | + $ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title; |
|
181 | 181 | } |
182 | 182 | |
183 | - $ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : ''; |
|
183 | + $ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : ''; |
|
184 | 184 | |
185 | 185 | |
186 | 186 | //Return the name contents |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | /* $1%s */ $name_link, |
189 | 189 | /* $2%s */ $item->GRP_ID(), |
190 | 190 | /* %4$s */ $ctx_content, |
191 | - /* $3%s */ $this->row_actions( $actions ) |
|
191 | + /* $3%s */ $this->row_actions($actions) |
|
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @return string message_type name |
199 | 199 | */ |
200 | 200 | function column_message_type($item) { |
201 | - return ucwords($item->message_type_obj()->label['singular'] ); |
|
201 | + return ucwords($item->message_type_obj()->label['singular']); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | ) |
226 | 226 | ); |
227 | 227 | |
228 | - foreach ( $active_message_template_groups_grouped_by_messenger as $active_message_template_group ) { |
|
229 | - if ( $active_message_template_group instanceof EE_Message_Template_Group ) { |
|
228 | + foreach ($active_message_template_groups_grouped_by_messenger as $active_message_template_group) { |
|
229 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
230 | 230 | $messenger = $active_message_template_group->messenger_obj(); |
231 | 231 | $messenger_label = $messenger instanceof EE_messenger |
232 | 232 | ? $messenger->label['singular'] |
233 | 233 | : $active_message_template_group->messenger(); |
234 | - $messenger_options[ $active_message_template_group->messenger() ] = ucwords( $messenger_label ); |
|
234 | + $messenger_options[$active_message_template_group->messenger()] = ucwords($messenger_label); |
|
235 | 235 | } |
236 | 236 | } |
237 | - return $this->get_admin_page()->get_messengers_select_input( $messenger_options ); |
|
237 | + return $this->get_admin_page()->get_messengers_select_input($messenger_options); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | |
@@ -254,16 +254,16 @@ discard block |
||
254 | 254 | ) |
255 | 255 | ); |
256 | 256 | |
257 | - foreach ( $active_message_template_groups_grouped_by_message_type as $active_message_template_group ) { |
|
258 | - if ( $active_message_template_group instanceof EE_Message_Template_Group ) { |
|
257 | + foreach ($active_message_template_groups_grouped_by_message_type as $active_message_template_group) { |
|
258 | + if ($active_message_template_group instanceof EE_Message_Template_Group) { |
|
259 | 259 | $message_type = $active_message_template_group->message_type_obj(); |
260 | 260 | $message_type_label = $message_type instanceof EE_message_type |
261 | 261 | ? $message_type->label['singular'] |
262 | 262 | : $active_message_template_group->message_type(); |
263 | - $message_type_options[ $active_message_template_group->message_type() ] = ucwords( $message_type_label ); |
|
263 | + $message_type_options[$active_message_template_group->message_type()] = ucwords($message_type_label); |
|
264 | 264 | } |
265 | 265 | } |
266 | - return $this->get_admin_page()->get_message_types_select_input( $message_type_options ); |
|
266 | + return $this->get_admin_page()->get_message_types_select_input($message_type_options); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | |
93 | 93 | |
94 | 94 | private function _registration_trash_message() { |
95 | - return '<p>' . __('This lock-icon means that this registration cannot be trashed. Registrations that belong to a transaction that has payments cannot be trashed. If you wish to trash this registration then you must delete all payments attached to the related transaction first.', 'event_espresso') . '</p>'; |
|
95 | + return '<p>'.__('This lock-icon means that this registration cannot be trashed. Registrations that belong to a transaction that has payments cannot be trashed. If you wish to trash this registration then you must delete all payments attached to the related transaction first.', 'event_espresso').'</p>'; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param EEM_Registration constant $status What status is set (by class) |
105 | 105 | * @return string The status legend with the related status highlighted |
106 | 106 | */ |
107 | - private function _registration_status_legend( $status ) { |
|
107 | + private function _registration_status_legend($status) { |
|
108 | 108 | |
109 | 109 | $status_array = array( |
110 | 110 | 'approved_status' => EEM_Registration::status_id_approved, |
@@ -114,6 +114,6 @@ discard block |
||
114 | 114 | 'cancelled_status' => EEM_Registration::status_id_cancelled |
115 | 115 | ); |
116 | 116 | |
117 | - return EEH_Template::status_legend( $status_array, $status ); |
|
117 | + return EEH_Template::status_legend($status_array, $status); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param EEM_Transaction constant $status What status is set (by class) |
84 | 84 | * @return string The status legend with the related status highlighted |
85 | 85 | */ |
86 | - private function _transaction_status_legend( $status ) { |
|
86 | + private function _transaction_status_legend($status) { |
|
87 | 87 | |
88 | 88 | $status_array = array( |
89 | 89 | 'overpaid' => EEM_Transaction::overpaid_status_code, |
@@ -92,6 +92,6 @@ discard block |
||
92 | 92 | 'failed' => EEM_Transaction::failed_status_code, |
93 | 93 | ); |
94 | 94 | |
95 | - return EEH_Template::status_legend( $status_array, $status ); |
|
95 | + return EEH_Template::status_legend($status_array, $status); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -2,25 +2,25 @@ |
||
2 | 2 | //this displays any legends with an array of $items that are indexed by id for each item and each item itself is an array of 'icon' and 'desc'. |
3 | 3 | |
4 | 4 | //figure out the columns based on the count of items (we want a max of 6 items per column). |
5 | -$per_col = isset( $per_column ) ? $per_column : 5; |
|
5 | +$per_col = isset($per_column) ? $per_column : 5; |
|
6 | 6 | $count = 1; |
7 | 7 | ?> |
8 | 8 | <div class="ee-list-table-legend-container"> |
9 | 9 | <h4><?php _e('Legend', 'event_espresso'); ?></h4> |
10 | 10 | <dl class="alignleft ee-list-table-legend"> |
11 | - <?php foreach ( $items as $item => $details ) : ?> |
|
12 | - <?php if ( $per_col < $count ) : ?> |
|
11 | + <?php foreach ($items as $item => $details) : ?> |
|
12 | + <?php if ($per_col < $count) : ?> |
|
13 | 13 | </dl> |
14 | 14 | <dl class="alignleft ee-list-table-legend"> |
15 | 15 | <?php $count = 1; endif; ?> |
16 | 16 | <dt id="ee-legend-item-<?php echo $item; ?>"> |
17 | - <?php $class = ! empty( $details['class'] ) ? $details['class'] : 'ee-legend-img-container'; ?> |
|
18 | - <?php if ( strpos( $details[ 'class' ], '<span' ) !== false ) { |
|
17 | + <?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?> |
|
18 | + <?php if (strpos($details['class'], '<span') !== false) { |
|
19 | 19 | echo $class; |
20 | 20 | } else { ?> |
21 | 21 | <span class="<?php echo $class; ?>"> |
22 | - <?php if ( ! empty( $details[ 'icon' ] ) ) : ?> |
|
23 | - <img src="<?php echo $details[ 'icon' ]; ?>" class="ee-legend-icon" alt="<?php echo esc_attr( $details[ 'desc' ] ); ?>"/> |
|
22 | + <?php if ( ! empty($details['icon'])) : ?> |
|
23 | + <img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" alt="<?php echo esc_attr($details['desc']); ?>"/> |
|
24 | 24 | <?php endif; ?> |
25 | 25 | </span> |
26 | 26 | <?php } ?> |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed','event_espresso'), false, false) |
56 | 56 | ) |
57 | 57 | */ |
58 | -class EE_DMS_4_1_0_questions extends EE_Data_Migration_Script_Stage{ |
|
58 | +class EE_DMS_4_1_0_questions extends EE_Data_Migration_Script_Stage { |
|
59 | 59 | private $_old_table; |
60 | 60 | private $_new_table; |
61 | 61 | private $_option_table; |
62 | - function _migration_step($num_items=50){ |
|
62 | + function _migration_step($num_items = 50) { |
|
63 | 63 | global $wpdb; |
64 | 64 | $start_at_record = $this->count_records_migrated(); |
65 | - $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d",$start_at_record,$num_items),ARRAY_A); |
|
65 | + $rows = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->_old_table LIMIT %d,%d", $start_at_record, $num_items), ARRAY_A); |
|
66 | 66 | $items_actually_migrated = 0; |
67 | - foreach($rows as $question_row){ |
|
67 | + foreach ($rows as $question_row) { |
|
68 | 68 | $new_id = $this->_insert_new_question($question_row); |
69 | 69 | $this->get_migration_script()->set_mapping($this->_old_table, $question_row['id'], $this->_new_table, $new_id); |
70 | 70 | $items_actually_migrated++; |
71 | 71 | } |
72 | - if($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()){ |
|
72 | + if ($this->count_records_migrated() + $items_actually_migrated >= $this->count_records_to_migrate()) { |
|
73 | 73 | $this->set_completed(); |
74 | 74 | } |
75 | 75 | return $items_actually_migrated; |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | $this->_option_table = $wpdb->prefix."esp_question_option"; |
88 | 88 | parent::__construct(); |
89 | 89 | } |
90 | - private function _insert_new_question($old_question){ |
|
90 | + private function _insert_new_question($old_question) { |
|
91 | 91 | global $wpdb; |
92 | 92 | //if this pretends to be a 'system' question, check if we already have a |
93 | 93 | //system question for that string. If so, pretend THAT new question |
94 | 94 | //is what we just isnerted |
95 | - if($old_question['system_name']){ |
|
96 | - $id_of_new_system_question = intval($wpdb->get_var($wpdb->prepare("SELECT QST_ID FROM {$this->_new_table} WHERE QST_system = %s",$old_question['system_name']))); |
|
97 | - if($id_of_new_system_question){ |
|
95 | + if ($old_question['system_name']) { |
|
96 | + $id_of_new_system_question = intval($wpdb->get_var($wpdb->prepare("SELECT QST_ID FROM {$this->_new_table} WHERE QST_system = %s", $old_question['system_name']))); |
|
97 | + if ($id_of_new_system_question) { |
|
98 | 98 | return $id_of_new_system_question; |
99 | 99 | } |
100 | 100 | //ok so this must be the first one. Carry on. |
@@ -113,27 +113,27 @@ discard block |
||
113 | 113 | 'QST_deleted'=>false |
114 | 114 | ); |
115 | 115 | $datatypes = array( |
116 | - '%s',//QST_display_text |
|
117 | - '%s',//QST-admin_label |
|
118 | - '%s',//QST_system |
|
119 | - '%s',//QST_type |
|
120 | - '%d',//QST_required |
|
121 | - '%s',//QST_required_text |
|
122 | - '%d',//QST_order |
|
123 | - '%d',//QST_admin_only |
|
124 | - '%d',//QST_wp_user |
|
125 | - '%d',//QST_deleted |
|
116 | + '%s', //QST_display_text |
|
117 | + '%s', //QST-admin_label |
|
118 | + '%s', //QST_system |
|
119 | + '%s', //QST_type |
|
120 | + '%d', //QST_required |
|
121 | + '%s', //QST_required_text |
|
122 | + '%d', //QST_order |
|
123 | + '%d', //QST_admin_only |
|
124 | + '%d', //QST_wp_user |
|
125 | + '%d', //QST_deleted |
|
126 | 126 | ); |
127 | - $success = $wpdb->insert($this->_new_table,$cols_n_values,$datatypes); |
|
128 | - if ( ! $success){ |
|
127 | + $success = $wpdb->insert($this->_new_table, $cols_n_values, $datatypes); |
|
128 | + if ( ! $success) { |
|
129 | 129 | $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, $old_question, $this->_new_table, $cols_n_values, $datatypes)); |
130 | 130 | return 0; |
131 | 131 | } |
132 | 132 | $new_id = $wpdb->insert_id; |
133 | 133 | //now take care of posisbly adding question options |
134 | - if(in_array($old_question['question_type'],array('DROPDOWN','SINGLE','MULTIPLE'))){ |
|
135 | - $options = explode(",",$old_question['response']); |
|
136 | - foreach($options as $option){ |
|
134 | + if (in_array($old_question['question_type'], array('DROPDOWN', 'SINGLE', 'MULTIPLE'))) { |
|
135 | + $options = explode(",", $old_question['response']); |
|
136 | + foreach ($options as $option) { |
|
137 | 137 | $this->_insert_question_option($option, $new_id); |
138 | 138 | } |
139 | 139 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | * @param int $question_id |
147 | 147 | * @return int |
148 | 148 | */ |
149 | - private function _insert_question_option($option,$question_id){ |
|
149 | + private function _insert_question_option($option, $question_id) { |
|
150 | 150 | $option = trim($option); |
151 | 151 | global $wpdb; |
152 | 152 | $cols_n_values = array( |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | 'QSO_value'=>$option, |
155 | 155 | 'QSO_deleted'=>false |
156 | 156 | ); |
157 | - $datatypes= array( |
|
158 | - '%d',//QST_ID |
|
159 | - '%s',//QSO_value |
|
160 | - '%d',//QSO_deleted |
|
157 | + $datatypes = array( |
|
158 | + '%d', //QST_ID |
|
159 | + '%s', //QSO_value |
|
160 | + '%d', //QSO_deleted |
|
161 | 161 | ); |
162 | - $success = $wpdb->insert($this->_option_table,$cols_n_values,$datatypes); |
|
163 | - if ( ! $success ){ |
|
164 | - $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option,'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
162 | + $success = $wpdb->insert($this->_option_table, $cols_n_values, $datatypes); |
|
163 | + if ( ! $success) { |
|
164 | + $this->add_error($this->get_migration_script()->_create_error_message_for_db_insertion($this->_old_table, array('option'=>$option, 'new_question_id'=>$question_id), $this->_option_table, $cols_n_values, $datatypes)); |
|
165 | 165 | return 0; |
166 | 166 | } |
167 | 167 | return $wpdb->insert_id; |