@@ -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 | /** |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | protected function _stop_one() { |
112 | - $content = '<h3>' . __('Edit Venue', 'event_espresso') . '</h3>'; |
|
113 | - $content .= '<p>' . __('This tour of the Venue Editor page will provide an overview of the different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>'; |
|
112 | + $content = '<h3>'.__('Edit Venue', 'event_espresso').'</h3>'; |
|
113 | + $content .= '<p>'.__('This tour of the Venue Editor page will provide an overview of the different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>'; |
|
114 | 114 | return $content; |
115 | 115 | } |
116 | 116 | |
@@ -119,35 +119,35 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | protected function _venue_editor_stop() { |
122 | - return '<p>' . __('The rich text editor can be used to edit information about your venue. Images and links can also be added or removed along with your text.', 'event_espresso') . '</p>'; |
|
122 | + return '<p>'.__('The rich text editor can be used to edit information about your venue. Images and links can also be added or removed along with your text.', 'event_espresso').'</p>'; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | protected function _venue_tags_stop() { |
126 | - return '<p>' . __('Quickly edit tags for your venue.', 'event_espresso') . '</p>'; |
|
126 | + return '<p>'.__('Quickly edit tags for your venue.', 'event_espresso').'</p>'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | protected function _venue_categories_stop() { |
130 | - return '<p>' . __('Venues can also be categorized if you wish.', 'event_espresso') . '</p>'; |
|
130 | + return '<p>'.__('Venues can also be categorized if you wish.', 'event_espresso').'</p>'; |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _venue_physical_location_stop() { |
134 | - return '<p>' . __('Edit the physical address for your venue.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('Edit the physical address for your venue.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _venue_gmap_stop() { |
138 | - return '<p>' . __('Enable or disable a Google Map for your venue.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('Enable or disable a Google Map for your venue.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _venue_virtual_location_stop() { |
142 | - return '<p>' . __('Setup a virtual location for your venue.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('Setup a virtual location for your venue.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | protected function _stop_featured_image() { |
146 | - return '<p>' . __('Set a feature image for your venue here.', 'event_espresso') . '</p>'; |
|
146 | + return '<p>'.__('Set a feature image for your venue here.', 'event_espresso').'</p>'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function _stop_publish_box() { |
150 | - return '<p>' . __('Easily control the status of your venue. The main options are Published, Pending Review, and Draft.', 'event_espresso') . '</p>'; |
|
150 | + return '<p>'.__('Easily control the status of your venue. The main options are Published, Pending Review, and Draft.', 'event_espresso').'</p>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | } |
154 | 154 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
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 |
@@ -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 | /** |
@@ -125,44 +125,44 @@ discard block |
||
125 | 125 | |
126 | 126 | |
127 | 127 | protected function _start() { |
128 | - $content = '<h3>' . __('Venue Overview', 'event_espresso') . '</h3>'; |
|
129 | - $content .= '<p>' . __('This tour of the Venues Overview page will provide an overview of the different areas of the screen to help you understand what they are used for.', 'event_espresso') . '</p>'; |
|
128 | + $content = '<h3>'.__('Venue Overview', 'event_espresso').'</h3>'; |
|
129 | + $content .= '<p>'.__('This tour of the Venues Overview page will provide an overview of the different areas of the screen to help you understand what they are used for.', 'event_espresso').'</p>'; |
|
130 | 130 | return $content; |
131 | 131 | } |
132 | 132 | |
133 | 133 | protected function _id_stop() { |
134 | - return '<p>' . __('View the venue ID. Can be sorted by ascending or descending order.', 'event_espresso') . '</p>'; |
|
134 | + return '<p>'.__('View the venue ID. Can be sorted by ascending or descending order.', 'event_espresso').'</p>'; |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | protected function _name_stop() { |
138 | - return '<p>' . __('View the name of each venue. Can be sorted by ascending or descending order.', 'event_espresso') . '</p>'; |
|
138 | + return '<p>'.__('View the name of each venue. Can be sorted by ascending or descending order.', 'event_espresso').'</p>'; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | protected function _address_stop() { |
142 | - return '<p>' . __('View the address for each venue.', 'event_espresso') . '</p>'; |
|
142 | + return '<p>'.__('View the address for each venue.', 'event_espresso').'</p>'; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | protected function _city_stop() { |
146 | - return '<p>' . __('View the city for each venue. Can be sorted by ascending or descending order.', 'event_espresso') . '</p>'; |
|
146 | + return '<p>'.__('View the city for each venue. Can be sorted by ascending or descending order.', 'event_espresso').'</p>'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | protected function _capacity_stop() { |
150 | - return '<p>' . __('View the capacity for each venue. Can be sorted by ascending or descending order.', 'event_espresso') . '</p>'; |
|
150 | + return '<p>'.__('View the capacity for each venue. Can be sorted by ascending or descending order.', 'event_espresso').'</p>'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | protected function _shortcode_stop() { |
154 | - return '<p>' . __('View the shortcode for a venue. This shortcode can be added to an event, WordPress post, or WordPress page. ', 'event_espresso') . '</p>'; |
|
154 | + return '<p>'.__('View the shortcode for a venue. This shortcode can be added to an event, WordPress post, or WordPress page. ', 'event_espresso').'</p>'; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | protected function _bulk_actions_stop() { |
158 | - return '<p>' . __('Perform bulk actions to multiple venues.', 'event_espresso') . '</p>'; |
|
158 | + return '<p>'.__('Perform bulk actions to multiple venues.', 'event_espresso').'</p>'; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | protected function _search_stop() { |
162 | - return '<p>' . __('Search through venues. The following sources will be searched: Venue Name, Venue Description, Venue Short Description, Venue Address, Venue City, Venue Zip/Postal Code, Venue Phone, Venue URL, Venue Virtual Phone, Venue Google Map link, Event Name, Event Description, Event Phone, and Event External URL.', 'event_espresso') . '</p>'; |
|
162 | + return '<p>'.__('Search through venues. The following sources will be searched: Venue Name, Venue Description, Venue Short Description, Venue Address, Venue City, Venue Zip/Postal Code, Venue Phone, Venue URL, Venue Virtual Phone, Venue Google Map link, Event Name, Event Description, Event Phone, and Event External URL.', 'event_espresso').'</p>'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | protected function _new_venue_stop() { |
166 | - return '<p>' . __('Click here to add a new venue.', 'event_espresso') . '</p>'; |
|
166 | + return '<p>'.__('Click here to add a new venue.', 'event_espresso').'</p>'; |
|
167 | 167 | } |
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
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 |
@@ -3,11 +3,11 @@ discard block |
||
3 | 3 | <td valign="top" class="use-ven-manager"> |
4 | 4 | <label><?php _e('Select from Venue Manager List', 'event_espresso'); ?></label> |
5 | 5 | <?php echo $venue_selector; ?> |
6 | - <?php foreach ( $venues as $venue ) : |
|
6 | + <?php foreach ($venues as $venue) : |
|
7 | 7 | $selected = $evt_venue_id == $venue->ID() ? '' : ' style="display:none;"'; |
8 | - $edit_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'edit', 'post' => $venue->ID() ), EE_VENUES_ADMIN_URL ); |
|
9 | - $state_name = is_object( $venue->state_obj() ) ? $venue->state_obj()->name() : NULL; |
|
10 | - $country_name = is_object( $venue->country_obj() ) ? $venue->country_obj()->name() : NULL; |
|
8 | + $edit_url = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $venue->ID()), EE_VENUES_ADMIN_URL); |
|
9 | + $state_name = is_object($venue->state_obj()) ? $venue->state_obj()->name() : NULL; |
|
10 | + $country_name = is_object($venue->country_obj()) ? $venue->country_obj()->name() : NULL; |
|
11 | 11 | ?> |
12 | 12 | <fieldset id="eebox_<?php echo $venue->ID(); ?>" class="eebox"<?php echo $selected; ?>> |
13 | 13 | <ul class="address-view"> |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | <span><?php _e('State:', 'event_espresso'); ?></span> <?php echo $state_name; ?><br /> |
19 | 19 | <span><?php _e('Country:', 'event_espresso'); ?></span> <?php echo $country_name; ?><br /> |
20 | 20 | <span><?php _e('Venue ID:', 'event_espresso'); ?></span> <?php echo $venue->ID(); ?><br /></p> |
21 | - <!-- <?php printf( __('This venue\'s shortcode: %s[ESPRESSO_VENUE id="%d"]%s', 'event_espresso'), '<strong class="highlight">', $venue->ID(), '</strong>' ); ?><br /> --> |
|
21 | + <!-- <?php printf(__('This venue\'s shortcode: %s[ESPRESSO_VENUE id="%d"]%s', 'event_espresso'), '<strong class="highlight">', $venue->ID(), '</strong>'); ?><br /> --> |
|
22 | 22 | <a href="<?php echo $edit_url; ?>" target="_blank"><?php _e('Edit this Venue', 'event_espresso'); ?></a> |
23 | 23 | </li> |
24 | 24 | </ul> |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | <tr> |
3 | 3 | <td valign="top"> |
4 | 4 | <fieldset> |
5 | - <?php if( isset( EE_Registry::instance()->CFG->map_settings ) && isset( EE_Registry::instance()->CFG->map_settings->use_google_maps ) && EE_Registry::instance()->CFG->map_settings->use_google_maps ) { ?> |
|
5 | + <?php if (isset(EE_Registry::instance()->CFG->map_settings) && isset(EE_Registry::instance()->CFG->map_settings->use_google_maps) && EE_Registry::instance()->CFG->map_settings->use_google_maps) { ?> |
|
6 | 6 | <p> |
7 | 7 | <label for="enable_for_gmap"> |
8 | 8 | <?php _e('Display Google Map for this venue? ', 'event_espresso') ?> |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | <input type="text" name="vnu_google_map_link" value="<?php echo $vnu_google_map_link; ?>" class="all-options" /> |
15 | 15 | </p> --> |
16 | 16 | <?php } ?> |
17 | - <?php if( ! isset( EE_Registry::instance()->CFG->map_settings ) || ! isset( EE_Registry::instance()->CFG->map_settings->use_google_maps ) || ! EE_Registry::instance()->CFG->map_settings->use_google_maps ) { ?> |
|
17 | + <?php if ( ! isset(EE_Registry::instance()->CFG->map_settings) || ! isset(EE_Registry::instance()->CFG->map_settings->use_google_maps) || ! EE_Registry::instance()->CFG->map_settings->use_google_maps) { ?> |
|
18 | 18 | <p class="ee-notice"> |
19 | 19 | <?php |
20 | 20 | echo sprintf( |
21 | - __('To display a Google Map for event venues, go to %sEvent Espresso General Settings%sGoogle Maps%s, and set "Activate Google Maps" to "Yes"', 'event_espresso' ), |
|
21 | + __('To display a Google Map for event venues, go to %sEvent Espresso General Settings%sGoogle Maps%s, and set "Activate Google Maps" to "Yes"', 'event_espresso'), |
|
22 | 22 | '<b>', |
23 | 23 | '</b> » <b>', |
24 | 24 | '</b>' |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | 'quantity'=>$line_item->quantity() |
49 | 49 | ); |
50 | 50 | } |
51 | - }else{//its a partial payment |
|
51 | + } else{//its a partial payment |
|
52 | 52 | $tax_total = 0; |
53 | 53 | //partial payment, so just add 1 item |
54 | 54 | $items[] = array( |
@@ -113,19 +113,19 @@ discard block |
||
113 | 113 | foreach($response_body_as_array as $problem_parameter => $problems){ |
114 | 114 | $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
115 | 115 | } |
116 | - }else{ |
|
116 | + } else{ |
|
117 | 117 | $problems_string = $response['body']; |
118 | 118 | } |
119 | 119 | if( ! $problems_string ) { |
120 | 120 | //no message to show? wack |
121 | 121 | if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
122 | 122 | $problems_string = $response[ 'headers' ][ 'status' ]; |
123 | - }else{ |
|
123 | + } else{ |
|
124 | 124 | $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | - }else{ |
|
128 | + } else{ |
|
129 | 129 | $problems_string = implode( ",", $response->get_error_messages() ); |
130 | 130 | } |
131 | 131 | |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | $prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum ); |
157 | 157 | } |
158 | 158 | return $prepared_data; |
159 | - }elseif(is_string( $data ) ){ |
|
159 | + } elseif(is_string( $data ) ){ |
|
160 | 160 | return str_replace( '%', 'percent', $data ); |
161 | - }else{ |
|
161 | + } else{ |
|
162 | 162 | return $data; |
163 | 163 | } |
164 | 164 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | $order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant ); |
105 | 105 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) ); |
106 | - $order = $this->_get_unsupported_character_remover()->formatArray($order); |
|
106 | + $order = $this->_get_unsupported_character_remover()->formatArray($order); |
|
107 | 107 | |
108 | 108 | $args = array( |
109 | 109 | 'headers' => array( |
@@ -113,45 +113,45 @@ discard block |
||
113 | 113 | 'body'=> wp_json_encode($order) |
114 | 114 | ); |
115 | 115 | $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
116 | - $problems_string = false; |
|
116 | + $problems_string = false; |
|
117 | 117 | $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
118 | 118 | if( ! $response instanceof WP_Error ){ |
119 | 119 | $response_body = json_decode($response['body']); |
120 | 120 | if($response_body && isset($response_body->checkout_url)){ |
121 | - $payment->set_redirect_url($response_body->checkout_url); |
|
122 | - $payment->set_txn_id_chq_nmbr($response_body->order_number); |
|
123 | - $payment->set_details($response['body']); |
|
121 | + $payment->set_redirect_url($response_body->checkout_url); |
|
122 | + $payment->set_txn_id_chq_nmbr($response_body->order_number); |
|
123 | + $payment->set_details($response['body']); |
|
124 | 124 | } else { |
125 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
126 | - $response_body_as_array = (array)$response_body; |
|
127 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
128 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
129 | - } |
|
130 | - }else{ |
|
131 | - $problems_string = $response['body']; |
|
132 | - } |
|
133 | - if( ! $problems_string ) { |
|
134 | - //no message to show? wack |
|
135 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
136 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
137 | - }else{ |
|
138 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
139 | - } |
|
140 | - } |
|
141 | - } |
|
125 | + if( is_array( $response_body ) || is_object( $response_body)){ |
|
126 | + $response_body_as_array = (array)$response_body; |
|
127 | + foreach($response_body_as_array as $problem_parameter => $problems){ |
|
128 | + $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
129 | + } |
|
130 | + }else{ |
|
131 | + $problems_string = $response['body']; |
|
132 | + } |
|
133 | + if( ! $problems_string ) { |
|
134 | + //no message to show? wack |
|
135 | + if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
136 | + $problems_string = $response[ 'headers' ][ 'status' ]; |
|
137 | + }else{ |
|
138 | + $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
139 | + } |
|
140 | + } |
|
141 | + } |
|
142 | 142 | }else{ |
143 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
143 | + $problems_string = implode( ",", $response->get_error_messages() ); |
|
144 | 144 | } |
145 | 145 | |
146 | - if( $problems_string ) { |
|
147 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
148 | - $payment->set_details( $response ); |
|
149 | - $payment->set_redirect_url( null ); |
|
150 | - //even though the payment's status is failed at this point anyways, |
|
151 | - //let's be explicit about it. The fact that the redirect url is null |
|
152 | - //should be enough to client code that they can't redirect the user |
|
153 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
154 | - } |
|
146 | + if( $problems_string ) { |
|
147 | + $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
148 | + $payment->set_details( $response ); |
|
149 | + $payment->set_redirect_url( null ); |
|
150 | + //even though the payment's status is failed at this point anyways, |
|
151 | + //let's be explicit about it. The fact that the redirect url is null |
|
152 | + //should be enough to client code that they can't redirect the user |
|
153 | + $payment->set_status( $this->_pay_model->failed_status() ); |
|
154 | + } |
|
155 | 155 | return $payment; |
156 | 156 | } |
157 | 157 | |
@@ -188,70 +188,70 @@ discard block |
||
188 | 188 | * @param array $update_info unused. We just use the $transaction |
189 | 189 | * @param EEI_Transaction $transaction |
190 | 190 | * @return \EEI_Payment |
191 | - * @throws EE_Error |
|
191 | + * @throws EE_Error |
|
192 | 192 | */ |
193 | 193 | public function handle_payment_update($update_info, $transaction) { |
194 | - foreach( $transaction->pending_payments() as $payment){ |
|
195 | - $payment = $this->check_payment_in_mijireh($payment); |
|
196 | - if( $payment->status() === $this->_pay_model->approved_status()){ |
|
197 | - return $payment; |
|
198 | - } |
|
199 | - } |
|
200 | - $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
|
194 | + foreach( $transaction->pending_payments() as $payment){ |
|
195 | + $payment = $this->check_payment_in_mijireh($payment); |
|
196 | + if( $payment->status() === $this->_pay_model->approved_status()){ |
|
197 | + return $payment; |
|
198 | + } |
|
199 | + } |
|
200 | + $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
|
201 | 201 | |
202 | - if ( ! $payment instanceof EEI_Payment ){ |
|
203 | - throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
204 | - } |
|
205 | - return $payment; |
|
202 | + if ( ! $payment instanceof EEI_Payment ){ |
|
203 | + throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
204 | + } |
|
205 | + return $payment; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | |
209 | 209 | |
210 | - /** |
|
211 | - * Checks the payment's status in Mijireh for this specific payment |
|
212 | - * @param \EEI_Payment $payment |
|
213 | - * @return \EEI_Payment |
|
214 | - */ |
|
210 | + /** |
|
211 | + * Checks the payment's status in Mijireh for this specific payment |
|
212 | + * @param \EEI_Payment $payment |
|
213 | + * @return \EEI_Payment |
|
214 | + */ |
|
215 | 215 | public function check_payment_in_mijireh( EEI_Payment $payment ){ |
216 | - $request_args = array( |
|
217 | - 'headers' => array( |
|
218 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
219 | - 'Accept'=>'application/json' |
|
220 | - ) |
|
221 | - ); |
|
216 | + $request_args = array( |
|
217 | + 'headers' => array( |
|
218 | + 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
219 | + 'Accept'=>'application/json' |
|
220 | + ) |
|
221 | + ); |
|
222 | 222 | |
223 | - $response = wp_remote_get( |
|
224 | - $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
225 | - $request_args |
|
226 | - ); |
|
223 | + $response = wp_remote_get( |
|
224 | + $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
225 | + $request_args |
|
226 | + ); |
|
227 | 227 | |
228 | - $this->log( |
|
229 | - array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
230 | - $payment |
|
231 | - ); |
|
232 | - // validate response |
|
233 | - $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
234 | - if( $response && $response_body ){ |
|
235 | - switch( $response_body->status ){ |
|
236 | - case 'paid': |
|
237 | - $payment->set_status($this->_pay_model->approved_status()); |
|
238 | - break; |
|
239 | - case 'pending': |
|
240 | - $payment->set_status($this->_pay_model->pending_status()); |
|
241 | - break; |
|
242 | - default: |
|
243 | - $payment->set_status($this->_pay_model->declined_status()); |
|
244 | - } |
|
228 | + $this->log( |
|
229 | + array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
230 | + $payment |
|
231 | + ); |
|
232 | + // validate response |
|
233 | + $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
234 | + if( $response && $response_body ){ |
|
235 | + switch( $response_body->status ){ |
|
236 | + case 'paid': |
|
237 | + $payment->set_status($this->_pay_model->approved_status()); |
|
238 | + break; |
|
239 | + case 'pending': |
|
240 | + $payment->set_status($this->_pay_model->pending_status()); |
|
241 | + break; |
|
242 | + default: |
|
243 | + $payment->set_status($this->_pay_model->declined_status()); |
|
244 | + } |
|
245 | 245 | |
246 | - } else { |
|
247 | - $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
248 | - $payment->set_details( $response ); |
|
249 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
250 | - } |
|
251 | - // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
|
246 | + } else { |
|
247 | + $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
248 | + $payment->set_details( $response ); |
|
249 | + $payment->set_status( $this->_pay_model->failed_status() ); |
|
250 | + } |
|
251 | + // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
|
252 | 252 | // $payment->set_status( $this->_pay_model->pending_status() ); |
253 | - return $payment; |
|
254 | - } |
|
253 | + return $payment; |
|
254 | + } |
|
255 | 255 | |
256 | 256 | } |
257 | 257 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @author Mike Nelson |
9 | 9 | * |
10 | 10 | */ |
11 | -class EEG_Mijireh extends EE_Offsite_Gateway{ |
|
11 | +class EEG_Mijireh extends EE_Offsite_Gateway { |
|
12 | 12 | |
13 | 13 | protected $_access_key; |
14 | 14 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | $primary_attendee = $primary_registrant->attendee(); |
38 | 38 | $items = array(); |
39 | 39 | //if we're are charging for the full amount, show the normal line items |
40 | - if( $this->_can_easily_itemize_transaction_for( $payment )){ |
|
40 | + if ($this->_can_easily_itemize_transaction_for($payment)) { |
|
41 | 41 | $total_line_item = $transaction->total_line_item(); |
42 | 42 | $tax_total = $total_line_item->get_total_tax(); |
43 | - foreach($total_line_item->get_items() as $line_item){ |
|
43 | + foreach ($total_line_item->get_items() as $line_item) { |
|
44 | 44 | $items[] = array( |
45 | 45 | 'name'=>apply_filters( |
46 | 46 | 'FHEE__EEG_Mijireh__set_redirection_info__full_amount_line_item_name', |
47 | - $this->_format_line_item_name( $line_item, $payment ), |
|
47 | + $this->_format_line_item_name($line_item, $payment), |
|
48 | 48 | $line_item, |
49 | 49 | $payment, |
50 | 50 | $primary_registrant |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | 'quantity'=>$line_item->quantity() |
55 | 55 | ); |
56 | 56 | } |
57 | - }else{//its a partial payment |
|
57 | + } else {//its a partial payment |
|
58 | 58 | $tax_total = 0; |
59 | 59 | //partial payment, so just add 1 item |
60 | 60 | $items[] = array( |
61 | 61 | 'name'=> apply_filters( |
62 | 62 | 'FHEE__EEG_Mijireh__set_redirection_info__partial_amount_line_item_name', |
63 | - $this->_format_partial_payment_line_item_name( $payment ), |
|
63 | + $this->_format_partial_payment_line_item_name($payment), |
|
64 | 64 | $payment, |
65 | 65 | $primary_registrant |
66 | 66 | ), |
@@ -72,18 +72,18 @@ discard block |
||
72 | 72 | $order = array( |
73 | 73 | 'total'=>$this->format_currency($payment->amount()), |
74 | 74 | 'return_url'=>$return_url, |
75 | - 'items'=>$this->_prepare_for_mijireh( $items ), |
|
75 | + 'items'=>$this->_prepare_for_mijireh($items), |
|
76 | 76 | 'email'=>$primary_attendee->email(), |
77 | 77 | 'first_name'=>$primary_attendee->fname(), |
78 | 78 | 'last_name'=>$primary_attendee->lname(), |
79 | 79 | 'tax'=>$this->format_currency($tax_total), |
80 | 80 | 'partner_id'=>'ee'); |
81 | 81 | //setup address? |
82 | - if( $primary_attendee->address() && |
|
83 | - $primary_attendee->city() && |
|
84 | - $primary_attendee->state_ID() && |
|
85 | - $primary_attendee->country_ID() && |
|
86 | - $primary_attendee->zip() ){ |
|
82 | + if ($primary_attendee->address() && |
|
83 | + $primary_attendee->city() && |
|
84 | + $primary_attendee->state_ID() && |
|
85 | + $primary_attendee->country_ID() && |
|
86 | + $primary_attendee->zip()) { |
|
87 | 87 | $shipping_address = array( |
88 | 88 | 'first_name'=>$primary_attendee->fname(), |
89 | 89 | 'last_name'=>$primary_attendee->lname(), |
@@ -93,64 +93,64 @@ discard block |
||
93 | 93 | 'zip_code' => $primary_attendee->zip(), |
94 | 94 | 'country' => $primary_attendee->country_ID() |
95 | 95 | ); |
96 | - if( $primary_attendee->address2() ){ |
|
97 | - $shipping_address[ 'apt_suite' ] = $primary_attendee->address2(); |
|
96 | + if ($primary_attendee->address2()) { |
|
97 | + $shipping_address['apt_suite'] = $primary_attendee->address2(); |
|
98 | 98 | } |
99 | - if( $primary_attendee->phone() ){ |
|
100 | - $shipping_address[ 'phone' ] = $primary_attendee->phone(); |
|
99 | + if ($primary_attendee->phone()) { |
|
100 | + $shipping_address['phone'] = $primary_attendee->phone(); |
|
101 | 101 | } |
102 | - $order[ 'shipping_address' ] = $shipping_address; |
|
102 | + $order['shipping_address'] = $shipping_address; |
|
103 | 103 | } |
104 | - $order = apply_filters( 'FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant ); |
|
105 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this)) ); |
|
104 | + $order = apply_filters('FHEE__EEG_Mijireh__set_redirection_info__order_arguments', $order, $payment, $primary_registrant); |
|
105 | + do_action('AHEE_log', __FILE__, __FUNCTION__, serialize(get_object_vars($this))); |
|
106 | 106 | $order = $this->_get_unsupported_character_remover()->formatArray($order); |
107 | 107 | |
108 | 108 | $args = array( |
109 | 109 | 'headers' => array( |
110 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
110 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
111 | 111 | 'Accept'=>'application/json' |
112 | 112 | ), |
113 | 113 | 'body'=> wp_json_encode($order) |
114 | 114 | ); |
115 | - $response = wp_remote_post( $this->_mijireh_api_orders_url, $args ); |
|
115 | + $response = wp_remote_post($this->_mijireh_api_orders_url, $args); |
|
116 | 116 | $problems_string = false; |
117 | - $this->log(array('get checkout url request_args' => $args, 'response' => $response ), $payment); |
|
118 | - if( ! $response instanceof WP_Error ){ |
|
117 | + $this->log(array('get checkout url request_args' => $args, 'response' => $response), $payment); |
|
118 | + if ( ! $response instanceof WP_Error) { |
|
119 | 119 | $response_body = json_decode($response['body']); |
120 | - if($response_body && isset($response_body->checkout_url)){ |
|
120 | + if ($response_body && isset($response_body->checkout_url)) { |
|
121 | 121 | $payment->set_redirect_url($response_body->checkout_url); |
122 | 122 | $payment->set_txn_id_chq_nmbr($response_body->order_number); |
123 | 123 | $payment->set_details($response['body']); |
124 | 124 | } else { |
125 | - if( is_array( $response_body ) || is_object( $response_body)){ |
|
126 | - $response_body_as_array = (array)$response_body; |
|
127 | - foreach($response_body_as_array as $problem_parameter => $problems){ |
|
128 | - $problems_string.= sprintf(__('\nProblems with %s: %s','event_espresso'),$problem_parameter,implode(", ",$problems)); |
|
125 | + if (is_array($response_body) || is_object($response_body)) { |
|
126 | + $response_body_as_array = (array) $response_body; |
|
127 | + foreach ($response_body_as_array as $problem_parameter => $problems) { |
|
128 | + $problems_string .= sprintf(__('\nProblems with %s: %s', 'event_espresso'), $problem_parameter, implode(", ", $problems)); |
|
129 | 129 | } |
130 | - }else{ |
|
130 | + } else { |
|
131 | 131 | $problems_string = $response['body']; |
132 | 132 | } |
133 | - if( ! $problems_string ) { |
|
133 | + if ( ! $problems_string) { |
|
134 | 134 | //no message to show? wack |
135 | - if( isset( $response[ 'headers' ][ 'status' ] ) ){ |
|
136 | - $problems_string = $response[ 'headers' ][ 'status' ]; |
|
137 | - }else{ |
|
138 | - $problems_string = __( 'No response from Mijireh', 'event_espresso' ); |
|
135 | + if (isset($response['headers']['status'])) { |
|
136 | + $problems_string = $response['headers']['status']; |
|
137 | + } else { |
|
138 | + $problems_string = __('No response from Mijireh', 'event_espresso'); |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
142 | - }else{ |
|
143 | - $problems_string = implode( ",", $response->get_error_messages() ); |
|
142 | + } else { |
|
143 | + $problems_string = implode(",", $response->get_error_messages()); |
|
144 | 144 | } |
145 | 145 | |
146 | - if( $problems_string ) { |
|
147 | - $payment->set_gateway_response( sprintf( __( 'Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string ) ); |
|
148 | - $payment->set_details( $response ); |
|
149 | - $payment->set_redirect_url( null ); |
|
146 | + if ($problems_string) { |
|
147 | + $payment->set_gateway_response(sprintf(__('Errors occurred communicating with Mijireh: %1$s', 'event_espresso'), $problems_string)); |
|
148 | + $payment->set_details($response); |
|
149 | + $payment->set_redirect_url(null); |
|
150 | 150 | //even though the payment's status is failed at this point anyways, |
151 | 151 | //let's be explicit about it. The fact that the redirect url is null |
152 | 152 | //should be enough to client code that they can't redirect the user |
153 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
153 | + $payment->set_status($this->_pay_model->failed_status()); |
|
154 | 154 | } |
155 | 155 | return $payment; |
156 | 156 | } |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | * @param mixed $data |
164 | 164 | * @return mixed same type as $data |
165 | 165 | */ |
166 | - private function _prepare_for_mijireh( $data ){ |
|
167 | - if( is_array( $data ) ){ |
|
166 | + private function _prepare_for_mijireh($data) { |
|
167 | + if (is_array($data)) { |
|
168 | 168 | $prepared_data = array(); |
169 | - foreach($data as $key => $datum ){ |
|
170 | - $prepared_data[ $key ] = $this->_prepare_for_mijireh( $datum ); |
|
169 | + foreach ($data as $key => $datum) { |
|
170 | + $prepared_data[$key] = $this->_prepare_for_mijireh($datum); |
|
171 | 171 | } |
172 | 172 | return $prepared_data; |
173 | - }elseif(is_string( $data ) ){ |
|
174 | - return str_replace( '%', 'percent', $data ); |
|
175 | - }else{ |
|
173 | + }elseif (is_string($data)) { |
|
174 | + return str_replace('%', 'percent', $data); |
|
175 | + } else { |
|
176 | 176 | return $data; |
177 | 177 | } |
178 | 178 | } |
@@ -191,16 +191,16 @@ discard block |
||
191 | 191 | * @throws EE_Error |
192 | 192 | */ |
193 | 193 | public function handle_payment_update($update_info, $transaction) { |
194 | - foreach( $transaction->pending_payments() as $payment){ |
|
194 | + foreach ($transaction->pending_payments() as $payment) { |
|
195 | 195 | $payment = $this->check_payment_in_mijireh($payment); |
196 | - if( $payment->status() === $this->_pay_model->approved_status()){ |
|
196 | + if ($payment->status() === $this->_pay_model->approved_status()) { |
|
197 | 197 | return $payment; |
198 | 198 | } |
199 | 199 | } |
200 | 200 | $payment = $transaction instanceof EEI_Transaction ? $transaction->last_payment() : NULL; |
201 | 201 | |
202 | - if ( ! $payment instanceof EEI_Payment ){ |
|
203 | - throw new EE_Error( sprintf( __( "Could not find Mijireh payment for transaction %s", 'event_espresso' ), $transaction->ID() ) ); |
|
202 | + if ( ! $payment instanceof EEI_Payment) { |
|
203 | + throw new EE_Error(sprintf(__("Could not find Mijireh payment for transaction %s", 'event_espresso'), $transaction->ID())); |
|
204 | 204 | } |
205 | 205 | return $payment; |
206 | 206 | } |
@@ -212,27 +212,27 @@ discard block |
||
212 | 212 | * @param \EEI_Payment $payment |
213 | 213 | * @return \EEI_Payment |
214 | 214 | */ |
215 | - public function check_payment_in_mijireh( EEI_Payment $payment ){ |
|
215 | + public function check_payment_in_mijireh(EEI_Payment $payment) { |
|
216 | 216 | $request_args = array( |
217 | 217 | 'headers' => array( |
218 | - 'Authorization' => 'Basic ' . base64_encode( $this->_access_key . ':' ), |
|
218 | + 'Authorization' => 'Basic '.base64_encode($this->_access_key.':'), |
|
219 | 219 | 'Accept'=>'application/json' |
220 | 220 | ) |
221 | 221 | ); |
222 | 222 | |
223 | 223 | $response = wp_remote_get( |
224 | - $this->_mijireh_api_orders_url . '/' . $payment->txn_id_chq_nmbr(), |
|
224 | + $this->_mijireh_api_orders_url.'/'.$payment->txn_id_chq_nmbr(), |
|
225 | 225 | $request_args |
226 | 226 | ); |
227 | 227 | |
228 | 228 | $this->log( |
229 | - array( 'get payment status request_args' => $request_args, 'response' => $response ), |
|
229 | + array('get payment status request_args' => $request_args, 'response' => $response), |
|
230 | 230 | $payment |
231 | 231 | ); |
232 | 232 | // validate response |
233 | - $response_body = isset( $response[ 'body' ] ) ? json_decode( $response[ 'body' ] ) : ''; |
|
234 | - if( $response && $response_body ){ |
|
235 | - switch( $response_body->status ){ |
|
233 | + $response_body = isset($response['body']) ? json_decode($response['body']) : ''; |
|
234 | + if ($response && $response_body) { |
|
235 | + switch ($response_body->status) { |
|
236 | 236 | case 'paid': |
237 | 237 | $payment->set_status($this->_pay_model->approved_status()); |
238 | 238 | break; |
@@ -244,9 +244,9 @@ discard block |
||
244 | 244 | } |
245 | 245 | |
246 | 246 | } else { |
247 | - $payment->set_gateway_response( __( 'Response from Mijireh could not be understood.', 'event_espresso' ) ); |
|
248 | - $payment->set_details( $response ); |
|
249 | - $payment->set_status( $this->_pay_model->failed_status() ); |
|
247 | + $payment->set_gateway_response(__('Response from Mijireh could not be understood.', 'event_espresso')); |
|
248 | + $payment->set_details($response); |
|
249 | + $payment->set_status($this->_pay_model->failed_status()); |
|
250 | 250 | } |
251 | 251 | // the following is ONLY for testing the Mijireh IPN and should NEVER be uncommented for real usage |
252 | 252 | // $payment->set_status( $this->_pay_model->pending_status() ); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php if (!defined('EVENT_ESPRESSO_VERSION')) |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | /** |
4 | - * mijireh_settings_after_form |
|
5 | - * |
|
6 | - * @package Event Espresso |
|
7 | - * @subpackage |
|
8 | - * @author Mike Nelson |
|
9 | - */ |
|
4 | + * mijireh_settings_after_form |
|
5 | + * |
|
6 | + * @package Event Espresso |
|
7 | + * @subpackage |
|
8 | + * @author Mike Nelson |
|
9 | + */ |
|
10 | 10 | do_action('AHEE__EE_Mijireh__settings_end'); |
11 | 11 | ?><br/><?php |
12 | 12 | // End of file mijireh_settings_after_form.template.php |
13 | 13 | \ No newline at end of file |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | /** |
4 | 4 | * mijireh_settings_after_form |
@@ -1,5 +1,6 @@ |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | 2 | exit('No direct script access allowed'); |
3 | +} |
|
3 | 4 | /** |
4 | 5 | * mijireh_settings_after_form |
5 | 6 | * |
@@ -500,11 +500,11 @@ |
||
500 | 500 | }else{ |
501 | 501 | $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
502 | 502 | } |
503 | - if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
504 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
505 | - } else { |
|
506 | - $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
507 | - } |
|
503 | + if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
504 | + $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
505 | + } else { |
|
506 | + $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
507 | + } |
|
508 | 508 | } |
509 | 509 | $registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row ); |
510 | 510 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | -do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
2 | +do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
3 | 3 | /** |
4 | 4 | * EE_Export class |
5 | 5 | * |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | * @access private |
40 | 40 | * @param array $request_data |
41 | 41 | */ |
42 | - private function __construct( $request_data = array() ) { |
|
42 | + private function __construct($request_data = array()) { |
|
43 | 43 | $this->_req_data = $request_data; |
44 | - $this->today = date("Y-m-d",time()); |
|
45 | - require_once( EE_CLASSES . 'EE_CSV.class.php' ); |
|
46 | - $this->EE_CSV= EE_CSV::instance(); |
|
44 | + $this->today = date("Y-m-d", time()); |
|
45 | + require_once(EE_CLASSES.'EE_CSV.class.php'); |
|
46 | + $this->EE_CSV = EE_CSV::instance(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * @param array $request_data |
56 | 56 | * @return \EE_Export |
57 | 57 | */ |
58 | - public static function instance( $request_data = array() ) { |
|
58 | + public static function instance($request_data = array()) { |
|
59 | 59 | // check if class object is instantiated |
60 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Export )) { |
|
61 | - self::$_instance = new self( $request_data ); |
|
60 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Export)) { |
|
61 | + self::$_instance = new self($request_data); |
|
62 | 62 | } |
63 | 63 | return self::$_instance; |
64 | 64 | } |
@@ -72,15 +72,15 @@ discard block |
||
72 | 72 | public function export() { |
73 | 73 | |
74 | 74 | // in case of bulk exports, the "actual" action will be in action2, but first check regular action for "export" keyword |
75 | - if ( isset( $this->_req_data['action'] ) && strpos( $this->_req_data['action'], 'export' ) === FALSE ) { |
|
75 | + if (isset($this->_req_data['action']) && strpos($this->_req_data['action'], 'export') === FALSE) { |
|
76 | 76 | // check if action2 has export action |
77 | - if ( isset( $this->_req_data['action2'] ) && strpos( $this->_req_data['action2'], 'export' ) !== FALSE ) { |
|
77 | + if (isset($this->_req_data['action2']) && strpos($this->_req_data['action2'], 'export') !== FALSE) { |
|
78 | 78 | // whoop! there it is! |
79 | 79 | $this->_req_data['action'] = $this->_req_data['action2']; |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | - $this->_req_data['export'] = isset( $this->_req_data['export'] ) ? $this->_req_data['export'] : ''; |
|
83 | + $this->_req_data['export'] = isset($this->_req_data['export']) ? $this->_req_data['export'] : ''; |
|
84 | 84 | |
85 | 85 | switch ($this->_req_data['export']) { |
86 | 86 | case 'report': |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | break; |
95 | 95 | |
96 | 96 | case 'registrations_report_for_event': |
97 | - $this->report_registrations_for_event( $this->_req_data['EVT_ID'] ); |
|
97 | + $this->report_registrations_for_event($this->_req_data['EVT_ID']); |
|
98 | 98 | break; |
99 | 99 | |
100 | 100 | case 'attendees': |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | break; |
107 | 107 | |
108 | 108 | default: |
109 | - EE_Error::add_error(__('An error occurred! The requested export report could not be found.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ) ; |
|
109 | + EE_Error::add_error(__('An error occurred! The requested export report could not be found.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
110 | 110 | return FALSE; |
111 | 111 | break; |
112 | 112 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * Downloads a CSV file with all the columns, but no data. This should be used for importing |
125 | 125 | * @return null kills execution |
126 | 126 | */ |
127 | - function export_sample(){ |
|
127 | + function export_sample() { |
|
128 | 128 | $event = EEM_Event::instance()->get_one(); |
129 | 129 | $this->_req_data['EVT_ID'] = $event->ID(); |
130 | 130 | $this->export_all_event_data(); |
@@ -150,23 +150,23 @@ discard block |
||
150 | 150 | $state_country_query_params = array(); |
151 | 151 | $question_group_query_params = array(); |
152 | 152 | $question_query_params = array(); |
153 | - if ( isset( $this->_req_data['EVT_ID'] )) { |
|
153 | + if (isset($this->_req_data['EVT_ID'])) { |
|
154 | 154 | // do we have an array of IDs ? |
155 | 155 | |
156 | - if ( is_array( $this->_req_data['EVT_ID'] )) { |
|
157 | - $EVT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_ID'] ); |
|
158 | - $value_to_equal = array('IN',$EVT_IDs); |
|
156 | + if (is_array($this->_req_data['EVT_ID'])) { |
|
157 | + $EVT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_ID']); |
|
158 | + $value_to_equal = array('IN', $EVT_IDs); |
|
159 | 159 | $filename = 'events'; |
160 | 160 | } else { |
161 | 161 | // generate regular where = clause |
162 | - $EVT_ID = absint( $this->_req_data['EVT_ID'] ); |
|
162 | + $EVT_ID = absint($this->_req_data['EVT_ID']); |
|
163 | 163 | $value_to_equal = $EVT_ID; |
164 | 164 | $event = EE_Registry::instance()->load_model('Event')->get_one_by_ID($EVT_ID); |
165 | 165 | |
166 | - $filename = 'event-' . ( $event instanceof EE_Event ? $event->slug() : __( 'unknown', 'event_espresso' ) ); |
|
166 | + $filename = 'event-'.($event instanceof EE_Event ? $event->slug() : __('unknown', 'event_espresso')); |
|
167 | 167 | |
168 | 168 | } |
169 | - $event_query_params[0]['EVT_ID'] =$value_to_equal; |
|
169 | + $event_query_params[0]['EVT_ID'] = $value_to_equal; |
|
170 | 170 | $related_models_query_params[0]['Event.EVT_ID'] = $value_to_equal; |
171 | 171 | $related_through_reg_query_params[0]['Registration.EVT_ID'] = $value_to_equal; |
172 | 172 | $datetime_ticket_query_params[0]['Datetime.EVT_ID'] = $value_to_equal; |
@@ -210,42 +210,42 @@ discard block |
||
210 | 210 | |
211 | 211 | ); |
212 | 212 | |
213 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
213 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
214 | 214 | |
215 | - $filename = $this->generate_filename ( $filename ); |
|
215 | + $filename = $this->generate_filename($filename); |
|
216 | 216 | |
217 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
218 | - EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
217 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
218 | + EE_Error::add_error(__("'An error occurred and the Event details could not be exported from the database.'", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | - function report_attendees(){ |
|
222 | + function report_attendees() { |
|
223 | 223 | $attendee_rows = EEM_Attendee::instance()->get_all_wpdb_results( |
224 | 224 | array( |
225 | - 'force_join' => array( 'State', 'Country' ), |
|
225 | + 'force_join' => array('State', 'Country'), |
|
226 | 226 | 'caps' => EEM_Base::caps_read_admin |
227 | 227 | ) |
228 | 228 | ); |
229 | 229 | $csv_data = array(); |
230 | - foreach( $attendee_rows as $attendee_row ){ |
|
230 | + foreach ($attendee_rows as $attendee_row) { |
|
231 | 231 | $csv_row = array(); |
232 | - foreach( EEM_Attendee::instance()->field_settings() as $field_name => $field_obj ){ |
|
233 | - if( $field_name == 'STA_ID' ){ |
|
234 | - $state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' ); |
|
235 | - $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
|
236 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
237 | - $country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
|
238 | - $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
|
239 | - }else{ |
|
240 | - $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
|
232 | + foreach (EEM_Attendee::instance()->field_settings() as $field_name => $field_obj) { |
|
233 | + if ($field_name == 'STA_ID') { |
|
234 | + $state_name_field = EEM_State::instance()->field_settings_for('STA_name'); |
|
235 | + $csv_row[__('State', 'event_espresso')] = $attendee_row[$state_name_field->get_qualified_column()]; |
|
236 | + }elseif ($field_name == 'CNT_ISO') { |
|
237 | + $country_name_field = EEM_Country::instance()->field_settings_for('CNT_name'); |
|
238 | + $csv_row[__('Country', 'event_espresso')] = $attendee_row[$country_name_field->get_qualified_column()]; |
|
239 | + } else { |
|
240 | + $csv_row[$field_obj->get_nicename()] = $attendee_row[$field_obj->get_qualified_column()]; |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | $csv_data[] = $csv_row; |
244 | 244 | } |
245 | 245 | |
246 | - $filename = $this->generate_filename ( 'contact-list-report' ); |
|
246 | + $filename = $this->generate_filename('contact-list-report'); |
|
247 | 247 | |
248 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
248 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
249 | 249 | $this->EE_CSV->write_data_array_to_csv($handle, $csv_data); |
250 | 250 | $this->EE_CSV->end_sending_csv($handle); |
251 | 251 | } |
@@ -262,18 +262,18 @@ discard block |
||
262 | 262 | $countries_that_have_an_attendee = EEM_Country::instance()->get_all(array(0=>array('Attendee.ATT_ID'=>array('IS NOT NULL')))); |
263 | 263 | // $states_to_export_query_params |
264 | 264 | $models_to_export = array( |
265 | - 'Country'=>array(array('CNT_ISO'=>array('IN',array_keys($countries_that_have_an_attendee)))), |
|
266 | - 'State'=>array(array('STA_ID'=>array('IN',array_keys($states_that_have_an_attendee)))), |
|
265 | + 'Country'=>array(array('CNT_ISO'=>array('IN', array_keys($countries_that_have_an_attendee)))), |
|
266 | + 'State'=>array(array('STA_ID'=>array('IN', array_keys($states_that_have_an_attendee)))), |
|
267 | 267 | 'Attendee'=>array(), |
268 | 268 | ); |
269 | 269 | |
270 | 270 | |
271 | 271 | |
272 | - $model_data = $this->_get_export_data_for_models( $models_to_export ); |
|
273 | - $filename = $this->generate_filename ( 'all-attendees' ); |
|
272 | + $model_data = $this->_get_export_data_for_models($models_to_export); |
|
273 | + $filename = $this->generate_filename('all-attendees'); |
|
274 | 274 | |
275 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $model_data )) { |
|
276 | - EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
275 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $model_data)) { |
|
276 | + EE_Error::add_error(__('An error occurred and the Attendee data could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -285,19 +285,19 @@ discard block |
||
285 | 285 | * @param boolean|string $pretty_schema true to display pretty, a string to use a specific "Schema", or false to NOT display pretty |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - protected function _prepare_value_from_db_for_display( $model, $field_name, $raw_db_value, $pretty_schema = true ) { |
|
289 | - $field_obj = $model->field_settings_for( $field_name ); |
|
290 | - $value_on_model_obj = $field_obj->prepare_for_set_from_db( $raw_db_value ); |
|
291 | - if( $field_obj instanceof EE_Datetime_Field ) { |
|
292 | - $field_obj->set_date_format( EE_CSV::instance()->get_date_format_for_csv( $field_obj->get_date_format( $pretty_schema ) ), $pretty_schema ); |
|
293 | - $field_obj->set_time_format( EE_CSV::instance()->get_time_format_for_csv( $field_obj->get_time_format( $pretty_schema ) ), $pretty_schema ); |
|
288 | + protected function _prepare_value_from_db_for_display($model, $field_name, $raw_db_value, $pretty_schema = true) { |
|
289 | + $field_obj = $model->field_settings_for($field_name); |
|
290 | + $value_on_model_obj = $field_obj->prepare_for_set_from_db($raw_db_value); |
|
291 | + if ($field_obj instanceof EE_Datetime_Field) { |
|
292 | + $field_obj->set_date_format(EE_CSV::instance()->get_date_format_for_csv($field_obj->get_date_format($pretty_schema)), $pretty_schema); |
|
293 | + $field_obj->set_time_format(EE_CSV::instance()->get_time_format_for_csv($field_obj->get_time_format($pretty_schema)), $pretty_schema); |
|
294 | 294 | } |
295 | - if( $pretty_schema === true){ |
|
296 | - return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
|
297 | - }elseif( is_string( $pretty_schema ) ) { |
|
298 | - return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
|
299 | - }else{ |
|
300 | - return $field_obj->prepare_for_get( $value_on_model_obj ); |
|
295 | + if ($pretty_schema === true) { |
|
296 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj); |
|
297 | + }elseif (is_string($pretty_schema)) { |
|
298 | + return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema); |
|
299 | + } else { |
|
300 | + return $field_obj->prepare_for_get($value_on_model_obj); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | * and the questions associated with the registrations |
307 | 307 | * @param int $event_id |
308 | 308 | */ |
309 | - function report_registrations_for_event( $event_id = NULL ){ |
|
309 | + function report_registrations_for_event($event_id = NULL) { |
|
310 | 310 | $reg_fields_to_include = array( |
311 | 311 | 'TXN_ID', |
312 | 312 | 'ATT_ID', |
@@ -338,126 +338,126 @@ discard block |
||
338 | 338 | array( |
339 | 339 | 'OR' => array( |
340 | 340 | //don't include registrations from failed or abandoned transactions... |
341 | - 'Transaction.STS_ID' => array( 'NOT IN', array( EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code ) ), |
|
341 | + 'Transaction.STS_ID' => array('NOT IN', array(EEM_Transaction::failed_status_code, EEM_Transaction::abandoned_status_code)), |
|
342 | 342 | //unless the registration is approved, in which case include it regardless of transaction status |
343 | 343 | 'STS_ID' => EEM_Registration::status_id_approved |
344 | 344 | ), |
345 | - 'Ticket.TKT_deleted' => array( 'IN', array( true, false ) ) |
|
345 | + 'Ticket.TKT_deleted' => array('IN', array(true, false)) |
|
346 | 346 | ), |
347 | - 'order_by' => array('Transaction.TXN_ID'=>'asc','REG_count'=>'asc'), |
|
348 | - 'force_join' => array( 'Transaction', 'Ticket', 'Attendee' ), |
|
347 | + 'order_by' => array('Transaction.TXN_ID'=>'asc', 'REG_count'=>'asc'), |
|
348 | + 'force_join' => array('Transaction', 'Ticket', 'Attendee'), |
|
349 | 349 | 'caps' => EEM_Base::caps_read_admin |
350 | 350 | ), |
351 | 351 | $event_id |
352 | 352 | ); |
353 | - if( $event_id ){ |
|
354 | - $query_params[0]['EVT_ID'] = $event_id; |
|
355 | - }else{ |
|
356 | - $query_params[ 'force_join' ][] = 'Event'; |
|
353 | + if ($event_id) { |
|
354 | + $query_params[0]['EVT_ID'] = $event_id; |
|
355 | + } else { |
|
356 | + $query_params['force_join'][] = 'Event'; |
|
357 | 357 | } |
358 | - $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
|
358 | + $registration_rows = $reg_model->get_all_wpdb_results($query_params); |
|
359 | 359 | //get all questions which relate to someone in this group |
360 | 360 | $registration_ids = array(); |
361 | - foreach( $registration_rows as $reg_row ) { |
|
362 | - $registration_ids[] = intval( $reg_row[ 'Registration.REG_ID'] ); |
|
361 | + foreach ($registration_rows as $reg_row) { |
|
362 | + $registration_ids[] = intval($reg_row['Registration.REG_ID']); |
|
363 | 363 | } |
364 | 364 | // EEM_Question::instance()->show_next_x_db_queries(); |
365 | - $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN',$registration_ids)))); |
|
366 | - foreach($registration_rows as $reg_row){ |
|
367 | - if ( is_array( $reg_row ) ) { |
|
365 | + $questions_for_these_regs_rows = EEM_Question::instance()->get_all_wpdb_results(array(array('Answer.REG_ID'=>array('IN', $registration_ids)))); |
|
366 | + foreach ($registration_rows as $reg_row) { |
|
367 | + if (is_array($reg_row)) { |
|
368 | 368 | $reg_csv_array = array(); |
369 | - if( ! $event_id ){ |
|
369 | + if ( ! $event_id) { |
|
370 | 370 | //get the event's name and Id |
371 | - $reg_csv_array[ __( 'Event', 'event_espresso' ) ] = sprintf( __( '%1$s (%2$s)', 'event_espresso' ), $this->_prepare_value_from_db_for_display( EEM_Event::instance(), 'EVT_name', $reg_row[ 'Event_CPT.post_title'] ), $reg_row[ 'Event_CPT.ID' ] ); |
|
371 | + $reg_csv_array[__('Event', 'event_espresso')] = sprintf(__('%1$s (%2$s)', 'event_espresso'), $this->_prepare_value_from_db_for_display(EEM_Event::instance(), 'EVT_name', $reg_row['Event_CPT.post_title']), $reg_row['Event_CPT.ID']); |
|
372 | 372 | } |
373 | - $is_primary_reg = $reg_row[ 'Registration.REG_count' ] == '1' ? true : false; |
|
373 | + $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false; |
|
374 | 374 | /*@var $reg_row EE_Registration */ |
375 | - foreach($reg_fields_to_include as $field_name){ |
|
375 | + foreach ($reg_fields_to_include as $field_name) { |
|
376 | 376 | $field = $reg_model->field_settings_for($field_name); |
377 | - if($field_name == 'REG_final_price'){ |
|
378 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
|
379 | - }elseif( $field_name == 'REG_count' ){ |
|
380 | - $value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
|
381 | - }elseif( $field_name == 'REG_date' ) { |
|
382 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
|
383 | - }else{ |
|
384 | - $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
|
377 | + if ($field_name == 'REG_final_price') { |
|
378 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_final_price'], 'localized_float'); |
|
379 | + }elseif ($field_name == 'REG_count') { |
|
380 | + $value = sprintf(__('%s of %s', 'event_espresso'), $this->_prepare_value_from_db_for_display($reg_model, 'REG_count', $reg_row['Registration.REG_count']), $this->_prepare_value_from_db_for_display($reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size'])); |
|
381 | + }elseif ($field_name == 'REG_date') { |
|
382 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row['Registration.REG_date'], 'no_html'); |
|
383 | + } else { |
|
384 | + $value = $this->_prepare_value_from_db_for_display($reg_model, $field_name, $reg_row[$field->get_qualified_column()]); |
|
385 | 385 | } |
386 | 386 | $reg_csv_array[$this->_get_column_name_for_field($field)] = $value; |
387 | - if($field_name == 'REG_final_price'){ |
|
387 | + if ($field_name == 'REG_final_price') { |
|
388 | 388 | //add a column named Currency after the final price |
389 | 389 | $reg_csv_array[__("Currency", "event_espresso")] = EE_Config::instance()->currency->code; |
390 | 390 | } |
391 | 391 | } |
392 | 392 | //get pretty status |
393 | - $stati = EEM_Status::instance()->localized_status( array( |
|
394 | - $reg_row[ 'Registration.STS_ID' ] => __( 'unknown', 'event_espresso' ), |
|
395 | - $reg_row[ 'TransactionTable.STS_ID' ] => __( 'unknown', 'event_espresso' ) ), |
|
393 | + $stati = EEM_Status::instance()->localized_status(array( |
|
394 | + $reg_row['Registration.STS_ID'] => __('unknown', 'event_espresso'), |
|
395 | + $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso') ), |
|
396 | 396 | FALSE, |
397 | - 'sentence' ); |
|
398 | - $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[ $reg_row[ 'Registration.STS_ID' ] ]; |
|
397 | + 'sentence'); |
|
398 | + $reg_csv_array[__("Registration Status", 'event_espresso')] = $stati[$reg_row['Registration.STS_ID']]; |
|
399 | 399 | //get pretty trnasaction status |
400 | - $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[ $reg_row[ 'TransactionTable.STS_ID' ] ]; |
|
401 | - $reg_csv_array[ __( 'Transaction Amount Due', 'event_espresso' ) ] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_total', $reg_row[ 'TransactionTable.TXN_total' ], 'localized_float' ) : '0.00'; |
|
402 | - $reg_csv_array[ __( 'Amount Paid', 'event_espresso' )] = $is_primary_reg ? $this->_prepare_value_from_db_for_display( EEM_Transaction::instance(), 'TXN_paid', $reg_row[ 'TransactionTable.TXN_paid' ], 'localized_float' ) : '0.00'; |
|
400 | + $reg_csv_array[__("Transaction Status", 'event_espresso')] = $stati[$reg_row['TransactionTable.STS_ID']]; |
|
401 | + $reg_csv_array[__('Transaction Amount Due', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_total', $reg_row['TransactionTable.TXN_total'], 'localized_float') : '0.00'; |
|
402 | + $reg_csv_array[__('Amount Paid', 'event_espresso')] = $is_primary_reg ? $this->_prepare_value_from_db_for_display(EEM_Transaction::instance(), 'TXN_paid', $reg_row['TransactionTable.TXN_paid'], 'localized_float') : '0.00'; |
|
403 | 403 | $payment_methods = array(); |
404 | 404 | $gateway_txn_ids_etc = array(); |
405 | 405 | $payment_times = array(); |
406 | - if( $is_primary_reg && $reg_row[ 'TransactionTable.TXN_ID' ] ){ |
|
406 | + if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) { |
|
407 | 407 | $payments_info = EEM_Payment::instance()->get_all_wpdb_results( |
408 | 408 | array( |
409 | 409 | array( |
410 | - 'TXN_ID' => $reg_row[ 'TransactionTable.TXN_ID' ], |
|
410 | + 'TXN_ID' => $reg_row['TransactionTable.TXN_ID'], |
|
411 | 411 | 'STS_ID' => EEM_Payment::status_id_approved |
412 | 412 | ), |
413 | - 'force_join' => array( 'Payment_Method' ), |
|
413 | + 'force_join' => array('Payment_Method'), |
|
414 | 414 | |
415 | 415 | ), |
416 | 416 | ARRAY_A, |
417 | 417 | 'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time' ); |
418 | 418 | |
419 | - foreach( $payments_info as $payment_method_and_gateway_txn_id ){ |
|
420 | - $payment_methods[] = isset( $payment_method_and_gateway_txn_id[ 'name' ] ) ? $payment_method_and_gateway_txn_id[ 'name' ] : __( 'Unknown', 'event_espresso' ); |
|
421 | - $gateway_txn_ids_etc[] = isset( $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] ) ? $payment_method_and_gateway_txn_id[ 'gateway_txn_id' ] : ''; |
|
422 | - $payment_times[] = isset( $payment_method_and_gateway_txn_id[ 'payment_time' ] ) ? $payment_method_and_gateway_txn_id[ 'payment_time' ] : ''; |
|
419 | + foreach ($payments_info as $payment_method_and_gateway_txn_id) { |
|
420 | + $payment_methods[] = isset($payment_method_and_gateway_txn_id['name']) ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso'); |
|
421 | + $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id']) ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : ''; |
|
422 | + $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time']) ? $payment_method_and_gateway_txn_id['payment_time'] : ''; |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | } |
426 | - $reg_csv_array[ __( 'Payment Date(s)', 'event_espresso' ) ] = implode( ',', $payment_times ); |
|
427 | - $reg_csv_array[ __( 'Payment Method(s)', 'event_espresso' ) ] = implode( ",", $payment_methods ); |
|
428 | - $reg_csv_array[ __( 'Gateway Transaction ID(s)', 'event_espresso' )] = implode( ',', $gateway_txn_ids_etc ); |
|
426 | + $reg_csv_array[__('Payment Date(s)', 'event_espresso')] = implode(',', $payment_times); |
|
427 | + $reg_csv_array[__('Payment Method(s)', 'event_espresso')] = implode(",", $payment_methods); |
|
428 | + $reg_csv_array[__('Gateway Transaction ID(s)', 'event_espresso')] = implode(',', $gateway_txn_ids_etc); |
|
429 | 429 | |
430 | 430 | //get whether or not the user has checked in |
431 | - $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related( $reg_row[ 'Registration.REG_ID'] , 'Checkin' ); |
|
431 | + $reg_csv_array[__("Check-Ins", "event_espresso")] = $reg_model->count_related($reg_row['Registration.REG_ID'], 'Checkin'); |
|
432 | 432 | //get ticket of registration and its price |
433 | 433 | $ticket_model = EE_Registry::instance()->load_model('Ticket'); |
434 | - if( $reg_row[ 'Ticket.TKT_ID'] ) { |
|
435 | - $ticket_name = $this->_prepare_value_from_db_for_display( $ticket_model, 'TKT_name', $reg_row[ 'Ticket.TKT_name' ] ); |
|
434 | + if ($reg_row['Ticket.TKT_ID']) { |
|
435 | + $ticket_name = $this->_prepare_value_from_db_for_display($ticket_model, 'TKT_name', $reg_row['Ticket.TKT_name']); |
|
436 | 436 | $datetimes_strings = array(); |
437 | - foreach( EEM_Datetime::instance()->get_all_wpdb_results( array( array( 'Ticket.TKT_ID' => $reg_row[ 'Ticket.TKT_ID' ] ), 'order_by' => array( 'DTT_EVT_start' => 'ASC' ), 'default_where_conditions' => 'none' ) ) as $datetime){ |
|
438 | - $datetimes_strings[] = $this->_prepare_value_from_db_for_display( EEM_Datetime::instance(), 'DTT_EVT_start', $datetime[ 'Datetime.DTT_EVT_start'] ); |
|
437 | + foreach (EEM_Datetime::instance()->get_all_wpdb_results(array(array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']), 'order_by' => array('DTT_EVT_start' => 'ASC'), 'default_where_conditions' => 'none')) as $datetime) { |
|
438 | + $datetimes_strings[] = $this->_prepare_value_from_db_for_display(EEM_Datetime::instance(), 'DTT_EVT_start', $datetime['Datetime.DTT_EVT_start']); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | } else { |
442 | - $ticket_name = __( 'Unknown', 'event_espresso' ); |
|
443 | - $datetimes_strings = array( __( 'Unknown', 'event_espresso' ) ); |
|
442 | + $ticket_name = __('Unknown', 'event_espresso'); |
|
443 | + $datetimes_strings = array(__('Unknown', 'event_espresso')); |
|
444 | 444 | } |
445 | 445 | $reg_csv_array[$ticket_model->field_settings_for('TKT_name')->get_nicename()] = $ticket_name; |
446 | 446 | $reg_csv_array[__("Datetimes of Ticket", "event_espresso")] = implode(", ", $datetimes_strings); |
447 | 447 | //get datetime(s) of registration |
448 | 448 | |
449 | 449 | //add attendee columns |
450 | - foreach($att_fields_to_include as $att_field_name){ |
|
450 | + foreach ($att_fields_to_include as $att_field_name) { |
|
451 | 451 | $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name); |
452 | - if( $reg_row[ 'Attendee_CPT.ID' ]){ |
|
453 | - if($att_field_name == 'STA_ID'){ |
|
454 | - $value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
|
455 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
456 | - $value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
|
457 | - }else{ |
|
458 | - $value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
|
452 | + if ($reg_row['Attendee_CPT.ID']) { |
|
453 | + if ($att_field_name == 'STA_ID') { |
|
454 | + $value = EEM_State::instance()->get_var(array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])), 'STA_name'); |
|
455 | + }elseif ($att_field_name == 'CNT_ISO') { |
|
456 | + $value = EEM_Country::instance()->get_var(array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])), 'CNT_name'); |
|
457 | + } else { |
|
458 | + $value = $this->_prepare_value_from_db_for_display(EEM_Attendee::instance(), $att_field_name, $reg_row[$field_obj->get_qualified_column()]); |
|
459 | 459 | } |
460 | - }else{ |
|
460 | + } else { |
|
461 | 461 | $value = ''; |
462 | 462 | } |
463 | 463 | |
@@ -465,56 +465,56 @@ discard block |
||
465 | 465 | } |
466 | 466 | |
467 | 467 | //make sure each registration has the same questions in the same order |
468 | - foreach($questions_for_these_regs_rows as $question_row){ |
|
469 | - if( ! isset($reg_csv_array[$question_row[ 'Question.QST_admin_label']])){ |
|
470 | - $reg_csv_array[$question_row[ 'Question.QST_admin_label' ] ] = null; |
|
468 | + foreach ($questions_for_these_regs_rows as $question_row) { |
|
469 | + if ( ! isset($reg_csv_array[$question_row['Question.QST_admin_label']])) { |
|
470 | + $reg_csv_array[$question_row['Question.QST_admin_label']] = null; |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | //now fill out the questions THEY answered |
474 | - foreach( EEM_Answer::instance()->get_all_wpdb_results( array( array( 'REG_ID' => $reg_row[ 'Registration.REG_ID' ] ), 'force_join' => array( 'Question' ) ) ) as $answer_row){ |
|
474 | + foreach (EEM_Answer::instance()->get_all_wpdb_results(array(array('REG_ID' => $reg_row['Registration.REG_ID']), 'force_join' => array('Question'))) as $answer_row) { |
|
475 | 475 | /* @var $answer EE_Answer */ |
476 | - if( $answer_row[ 'Question.QST_ID' ] ){ |
|
477 | - $question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] ); |
|
478 | - }else{ |
|
479 | - $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
|
476 | + if ($answer_row['Question.QST_ID']) { |
|
477 | + $question_label = $this->_prepare_value_from_db_for_display(EEM_Question::instance(), 'QST_admin_label', $answer_row['Question.QST_admin_label']); |
|
478 | + } else { |
|
479 | + $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']); |
|
480 | 480 | } |
481 | - if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
|
482 | - $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID( $answer_row[ 'Answer.ANS_value' ] ); |
|
481 | + if (isset($answer_row['Question.QST_type']) && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state) { |
|
482 | + $reg_csv_array[$question_label] = EEM_State::instance()->get_state_name_by_ID($answer_row['Answer.ANS_value']); |
|
483 | 483 | } else { |
484 | - $reg_csv_array[ $question_label ] = $this->_prepare_value_from_db_for_display( EEM_Answer::instance(), 'ANS_value', $answer_row[ 'Answer.ANS_value' ] ); |
|
484 | + $reg_csv_array[$question_label] = $this->_prepare_value_from_db_for_display(EEM_Answer::instance(), 'ANS_value', $answer_row['Answer.ANS_value']); |
|
485 | 485 | } |
486 | 486 | } |
487 | - $registrations_csv_ready_array[] = apply_filters( 'FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row ); |
|
487 | + $registrations_csv_ready_array[] = apply_filters('FHEE__EE_Export__report_registrations__reg_csv_array', $reg_csv_array, $reg_row); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | |
491 | 491 | //if we couldn't export anything, we want to at least show the column headers |
492 | - if(empty($registrations_csv_ready_array)){ |
|
492 | + if (empty($registrations_csv_ready_array)) { |
|
493 | 493 | $reg_csv_array = array(); |
494 | 494 | $model_and_fields_to_include = array( |
495 | 495 | 'Registration' => $reg_fields_to_include, |
496 | 496 | 'Attendee' => $att_fields_to_include |
497 | 497 | ); |
498 | - foreach($model_and_fields_to_include as $model_name => $field_list){ |
|
498 | + foreach ($model_and_fields_to_include as $model_name => $field_list) { |
|
499 | 499 | $model = EE_Registry::instance()->load_model($model_name); |
500 | - foreach($field_list as $field_name){ |
|
500 | + foreach ($field_list as $field_name) { |
|
501 | 501 | $field = $model->field_settings_for($field_name); |
502 | - $reg_csv_array[$this->_get_column_name_for_field($field)] = null;//$registration->get($field->get_name()); |
|
502 | + $reg_csv_array[$this->_get_column_name_for_field($field)] = null; //$registration->get($field->get_name()); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | $registrations_csv_ready_array [] = $reg_csv_array; |
506 | 506 | } |
507 | - if( $event_id ){ |
|
508 | - $event_slug = EEM_Event::instance()->get_var( array( array( 'EVT_ID' => $event_id ) ), 'EVT_slug' ); |
|
509 | - if( ! $event_slug ) { |
|
510 | - $event_slug = __( 'unknown', 'event_espresso' ); |
|
507 | + if ($event_id) { |
|
508 | + $event_slug = EEM_Event::instance()->get_var(array(array('EVT_ID' => $event_id)), 'EVT_slug'); |
|
509 | + if ( ! $event_slug) { |
|
510 | + $event_slug = __('unknown', 'event_espresso'); |
|
511 | 511 | } |
512 | - }else{ |
|
513 | - $event_slug = __( 'all', 'event_espresso' ); |
|
512 | + } else { |
|
513 | + $event_slug = __('all', 'event_espresso'); |
|
514 | 514 | } |
515 | - $filename = sprintf( "registrations-for-%s", $event_slug ); |
|
515 | + $filename = sprintf("registrations-for-%s", $event_slug); |
|
516 | 516 | |
517 | - $handle = $this->EE_CSV->begin_sending_csv( $filename); |
|
517 | + $handle = $this->EE_CSV->begin_sending_csv($filename); |
|
518 | 518 | $this->EE_CSV->write_data_array_to_csv($handle, $registrations_csv_ready_array); |
519 | 519 | $this->EE_CSV->end_sending_csv($handle); |
520 | 520 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | * @param EE_Model_Field_Base $field |
525 | 525 | * @return string |
526 | 526 | */ |
527 | - protected function _get_column_name_for_field(EE_Model_Field_Base $field){ |
|
527 | + protected function _get_column_name_for_field(EE_Model_Field_Base $field) { |
|
528 | 528 | return $field->get_nicename()."[".$field->get_name()."]"; |
529 | 529 | } |
530 | 530 | |
@@ -537,17 +537,17 @@ discard block |
||
537 | 537 | function export_categories() { |
538 | 538 | // are any Event IDs set? |
539 | 539 | $query_params = array(); |
540 | - if ( isset( $this->_req_data['EVT_CAT_ID'] )) { |
|
540 | + if (isset($this->_req_data['EVT_CAT_ID'])) { |
|
541 | 541 | // do we have an array of IDs ? |
542 | - if ( is_array( $this->_req_data['EVT_CAT_ID'] )) { |
|
542 | + if (is_array($this->_req_data['EVT_CAT_ID'])) { |
|
543 | 543 | // generate an "IN (CSV)" where clause |
544 | - $EVT_CAT_IDs = array_map( 'sanitize_text_field', $this->_req_data['EVT_CAT_ID'] ); |
|
544 | + $EVT_CAT_IDs = array_map('sanitize_text_field', $this->_req_data['EVT_CAT_ID']); |
|
545 | 545 | $filename = 'event-categories'; |
546 | - $query_params[0]['term_taxonomy_id'] = array('IN',$EVT_CAT_IDs); |
|
546 | + $query_params[0]['term_taxonomy_id'] = array('IN', $EVT_CAT_IDs); |
|
547 | 547 | } else { |
548 | 548 | // generate regular where = clause |
549 | - $EVT_CAT_ID = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
550 | - $filename = 'event-category#' . $EVT_CAT_ID; |
|
549 | + $EVT_CAT_ID = absint($this->_req_data['EVT_CAT_ID']); |
|
550 | + $filename = 'event-category#'.$EVT_CAT_ID; |
|
551 | 551 | $query_params[0]['term_taxonomy_id'] = $EVT_CAT_ID; |
552 | 552 | } |
553 | 553 | } else { |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | 'Term_Taxonomy' => $query_params |
560 | 560 | ); |
561 | 561 | |
562 | - $table_data = $this->_get_export_data_for_models( $tables_to_export ); |
|
563 | - $filename = $this->generate_filename ( $filename ); |
|
562 | + $table_data = $this->_get_export_data_for_models($tables_to_export); |
|
563 | + $filename = $this->generate_filename($filename); |
|
564 | 564 | |
565 | - if ( ! $this->EE_CSV->export_multiple_model_data_to_csv( $filename, $table_data )) { |
|
566 | - EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.','event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
565 | + if ( ! $this->EE_CSV->export_multiple_model_data_to_csv($filename, $table_data)) { |
|
566 | + EE_Error::add_error(__('An error occurred and the Category details could not be exported from the database.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
567 | 567 | } |
568 | 568 | } |
569 | 569 | |
@@ -574,13 +574,13 @@ discard block |
||
574 | 574 | * @param string - export_name |
575 | 575 | * @return string on success, FALSE on fail |
576 | 576 | */ |
577 | - private function generate_filename ( $export_name = '' ) { |
|
578 | - if ( $export_name != '' ) { |
|
579 | - $filename = get_bloginfo('name') . '-' . $export_name; |
|
580 | - $filename = sanitize_key( $filename ) . '-' . $this->today; |
|
577 | + private function generate_filename($export_name = '') { |
|
578 | + if ($export_name != '') { |
|
579 | + $filename = get_bloginfo('name').'-'.$export_name; |
|
580 | + $filename = sanitize_key($filename).'-'.$this->today; |
|
581 | 581 | return $filename; |
582 | - } else { |
|
583 | - EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
|
582 | + } else { |
|
583 | + EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__); |
|
584 | 584 | } |
585 | 585 | return false; |
586 | 586 | } |
@@ -593,12 +593,12 @@ discard block |
||
593 | 593 | * @param array $models_to_export keys are model names (eg 'Event', 'Attendee', etc.) and values are arrays of query params like on EEM_Base::get_all |
594 | 594 | * @return array on success, FALSE on fail |
595 | 595 | */ |
596 | - private function _get_export_data_for_models( $models_to_export = array() ) { |
|
596 | + private function _get_export_data_for_models($models_to_export = array()) { |
|
597 | 597 | $table_data = FALSE; |
598 | - if ( is_array( $models_to_export ) ) { |
|
599 | - foreach ( $models_to_export as $model_name => $query_params ) { |
|
598 | + if (is_array($models_to_export)) { |
|
599 | + foreach ($models_to_export as $model_name => $query_params) { |
|
600 | 600 | //check for a numerically-indexed array. in that case, $model_name is the value!! |
601 | - if(is_int($model_name)){ |
|
601 | + if (is_int($model_name)) { |
|
602 | 602 | $model_name = $query_params; |
603 | 603 | $query_params = array(); |
604 | 604 | } |
@@ -606,17 +606,17 @@ discard block |
||
606 | 606 | $model_objects = $model->get_all($query_params); |
607 | 607 | |
608 | 608 | $table_data[$model_name] = array(); |
609 | - foreach($model_objects as $model_object){ |
|
609 | + foreach ($model_objects as $model_object) { |
|
610 | 610 | $model_data_array = array(); |
611 | 611 | $fields = $model->field_settings(); |
612 | - foreach($fields as $field){ |
|
612 | + foreach ($fields as $field) { |
|
613 | 613 | $column_name = $field->get_nicename()."[".$field->get_name()."]"; |
614 | - if($field instanceof EE_Datetime_Field){ |
|
614 | + if ($field instanceof EE_Datetime_Field) { |
|
615 | 615 | // $field->set_date_format('Y-m-d'); |
616 | 616 | // $field->set_time_format('H:i:s'); |
617 | - $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s'); |
|
617 | + $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(), 'Y-m-d', 'H:i:s'); |
|
618 | 618 | } |
619 | - else{ |
|
619 | + else { |
|
620 | 620 | $model_data_array[$column_name] = $model_object->get($field->get_name()); |
621 | 621 | } |
622 | 622 | } |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
3 | 5 | /** |
4 | 6 | * EE_Export class |
@@ -233,10 +235,10 @@ discard block |
||
233 | 235 | if( $field_name == 'STA_ID' ){ |
234 | 236 | $state_name_field = EEM_State::instance()->field_settings_for( 'STA_name' ); |
235 | 237 | $csv_row[ __( 'State', 'event_espresso' ) ] = $attendee_row[ $state_name_field->get_qualified_column() ]; |
236 | - }elseif( $field_name == 'CNT_ISO' ){ |
|
238 | + } elseif( $field_name == 'CNT_ISO' ){ |
|
237 | 239 | $country_name_field = EEM_Country::instance()->field_settings_for( 'CNT_name' ); |
238 | 240 | $csv_row[ __( 'Country', 'event_espresso' ) ] = $attendee_row[ $country_name_field->get_qualified_column() ]; |
239 | - }else{ |
|
241 | + } else{ |
|
240 | 242 | $csv_row[ $field_obj->get_nicename() ] = $attendee_row[ $field_obj->get_qualified_column() ]; |
241 | 243 | } |
242 | 244 | } |
@@ -294,9 +296,9 @@ discard block |
||
294 | 296 | } |
295 | 297 | if( $pretty_schema === true){ |
296 | 298 | return $field_obj->prepare_for_pretty_echoing( $value_on_model_obj ); |
297 | - }elseif( is_string( $pretty_schema ) ) { |
|
299 | + } elseif( is_string( $pretty_schema ) ) { |
|
298 | 300 | return $field_obj->prepare_for_pretty_echoing($value_on_model_obj, $pretty_schema ); |
299 | - }else{ |
|
301 | + } else{ |
|
300 | 302 | return $field_obj->prepare_for_get( $value_on_model_obj ); |
301 | 303 | } |
302 | 304 | } |
@@ -352,7 +354,7 @@ discard block |
||
352 | 354 | ); |
353 | 355 | if( $event_id ){ |
354 | 356 | $query_params[0]['EVT_ID'] = $event_id; |
355 | - }else{ |
|
357 | + } else{ |
|
356 | 358 | $query_params[ 'force_join' ][] = 'Event'; |
357 | 359 | } |
358 | 360 | $registration_rows = $reg_model->get_all_wpdb_results( $query_params ); |
@@ -376,11 +378,11 @@ discard block |
||
376 | 378 | $field = $reg_model->field_settings_for($field_name); |
377 | 379 | if($field_name == 'REG_final_price'){ |
378 | 380 | $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_final_price'], 'localized_float' ); |
379 | - }elseif( $field_name == 'REG_count' ){ |
|
381 | + } elseif( $field_name == 'REG_count' ){ |
|
380 | 382 | $value = sprintf( __( '%s of %s', 'event_espresso' ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_count', $reg_row['Registration.REG_count'] ), $this->_prepare_value_from_db_for_display( $reg_model, 'REG_group_size', $reg_row['Registration.REG_group_size' ] ) ); |
381 | - }elseif( $field_name == 'REG_date' ) { |
|
383 | + } elseif( $field_name == 'REG_date' ) { |
|
382 | 384 | $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ 'Registration.REG_date'], 'no_html' ); |
383 | - }else{ |
|
385 | + } else{ |
|
384 | 386 | $value = $this->_prepare_value_from_db_for_display( $reg_model, $field_name, $reg_row[ $field->get_qualified_column() ] ); |
385 | 387 | } |
386 | 388 | $reg_csv_array[$this->_get_column_name_for_field($field)] = $value; |
@@ -452,12 +454,12 @@ discard block |
||
452 | 454 | if( $reg_row[ 'Attendee_CPT.ID' ]){ |
453 | 455 | if($att_field_name == 'STA_ID'){ |
454 | 456 | $value = EEM_State::instance()->get_var( array( array( 'STA_ID' => $reg_row[ 'Attendee_Meta.STA_ID' ] ) ), 'STA_name' ); |
455 | - }elseif($att_field_name == 'CNT_ISO'){ |
|
457 | + } elseif($att_field_name == 'CNT_ISO'){ |
|
456 | 458 | $value = EEM_Country::instance()->get_var( array( array( 'CNT_ISO' => $reg_row[ 'Attendee_Meta.CNT_ISO' ] ) ), 'CNT_name' ); |
457 | - }else{ |
|
459 | + } else{ |
|
458 | 460 | $value = $this->_prepare_value_from_db_for_display( EEM_Attendee::instance(), $att_field_name, $reg_row[ $field_obj->get_qualified_column() ] ); |
459 | 461 | } |
460 | - }else{ |
|
462 | + } else{ |
|
461 | 463 | $value = ''; |
462 | 464 | } |
463 | 465 | |
@@ -475,7 +477,7 @@ discard block |
||
475 | 477 | /* @var $answer EE_Answer */ |
476 | 478 | if( $answer_row[ 'Question.QST_ID' ] ){ |
477 | 479 | $question_label = $this->_prepare_value_from_db_for_display( EEM_Question::instance(), 'QST_admin_label', $answer_row[ 'Question.QST_admin_label' ] ); |
478 | - }else{ |
|
480 | + } else{ |
|
479 | 481 | $question_label = sprintf( __( 'Question $s', 'event_espresso' ), $answer_row[ 'Answer.QST_ID' ] ); |
480 | 482 | } |
481 | 483 | if( isset( $answer_row[ 'Question.QST_type'] ) && $answer_row[ 'Question.QST_type' ] == EEM_Question::QST_type_state ) { |
@@ -509,7 +511,7 @@ discard block |
||
509 | 511 | if( ! $event_slug ) { |
510 | 512 | $event_slug = __( 'unknown', 'event_espresso' ); |
511 | 513 | } |
512 | - }else{ |
|
514 | + } else{ |
|
513 | 515 | $event_slug = __( 'all', 'event_espresso' ); |
514 | 516 | } |
515 | 517 | $filename = sprintf( "registrations-for-%s", $event_slug ); |
@@ -579,7 +581,7 @@ discard block |
||
579 | 581 | $filename = get_bloginfo('name') . '-' . $export_name; |
580 | 582 | $filename = sanitize_key( $filename ) . '-' . $this->today; |
581 | 583 | return $filename; |
582 | - } else { |
|
584 | + } else { |
|
583 | 585 | EE_Error::add_error(__("No filename was provided", "event_espresso"), __FILE__, __FUNCTION__, __LINE__ ); |
584 | 586 | } |
585 | 587 | return false; |
@@ -615,8 +617,7 @@ discard block |
||
615 | 617 | // $field->set_date_format('Y-m-d'); |
616 | 618 | // $field->set_time_format('H:i:s'); |
617 | 619 | $model_data_array[$column_name] = $model_object->get_datetime($field->get_name(),'Y-m-d','H:i:s'); |
618 | - } |
|
619 | - else{ |
|
620 | + } else{ |
|
620 | 621 | $model_data_array[$column_name] = $model_object->get($field->get_name()); |
621 | 622 | } |
622 | 623 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * @param array $props_n_values |
31 | 31 | * @return EE_Post_Meta|mixed |
32 | 32 | */ |
33 | - public static function new_instance( $props_n_values = array() ) { |
|
34 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__ ); |
|
35 | - return $has_object ? $has_object : new self( $props_n_values ); |
|
33 | + public static function new_instance($props_n_values = array()) { |
|
34 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__); |
|
35 | + return $has_object ? $has_object : new self($props_n_values); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | * @param array $props_n_values |
42 | 42 | * @return EE_Post_Meta |
43 | 43 | */ |
44 | - public static function new_instance_from_db( $props_n_values = array() ) { |
|
45 | - return new self( $props_n_values, TRUE ); |
|
44 | + public static function new_instance_from_db($props_n_values = array()) { |
|
45 | + return new self($props_n_values, TRUE); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return int |
53 | 53 | */ |
54 | 54 | function meta_id() { |
55 | - return $this->get( 'meta_id' ); |
|
55 | + return $this->get('meta_id'); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -62,15 +62,15 @@ discard block |
||
62 | 62 | * @param int $meta_id |
63 | 63 | * @return boolean |
64 | 64 | */ |
65 | - function set_meta_id( $meta_id) { |
|
66 | - return $this->set( 'meta_id', $meta_id); |
|
65 | + function set_meta_id($meta_id) { |
|
66 | + return $this->set('meta_id', $meta_id); |
|
67 | 67 | } |
68 | 68 | /** |
69 | 69 | * Gets post_id |
70 | 70 | * @return int |
71 | 71 | */ |
72 | 72 | function post_id() { |
73 | - return $this->get( 'post_id' ); |
|
73 | + return $this->get('post_id'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @param int $post_id |
81 | 81 | * @return boolean |
82 | 82 | */ |
83 | - function set_post_id( $post_id) { |
|
84 | - return $this->set( 'post_id', $post_id); |
|
83 | + function set_post_id($post_id) { |
|
84 | + return $this->set('post_id', $post_id); |
|
85 | 85 | } |
86 | 86 | /** |
87 | 87 | * Gets meta_key |
88 | 88 | * @return string |
89 | 89 | */ |
90 | 90 | function meta_key() { |
91 | - return $this->get( 'meta_key' ); |
|
91 | + return $this->get('meta_key'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | * @param string $meta_key |
99 | 99 | * @return boolean |
100 | 100 | */ |
101 | - function set_meta_key( $meta_key) { |
|
102 | - return $this->set( 'meta_key', $meta_key); |
|
101 | + function set_meta_key($meta_key) { |
|
102 | + return $this->set('meta_key', $meta_key); |
|
103 | 103 | } |
104 | 104 | /** |
105 | 105 | * Gets meta_value |
106 | 106 | * @return mixed |
107 | 107 | */ |
108 | 108 | function meta_value() { |
109 | - return $this->get( 'meta_value' ); |
|
109 | + return $this->get('meta_value'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @param mixed $meta_value |
117 | 117 | * @return boolean |
118 | 118 | */ |
119 | - function set_meta_value( $meta_value) { |
|
120 | - return $this->set( 'meta_value', $meta_value); |
|
119 | + function set_meta_value($meta_value) { |
|
120 | + return $this->set('meta_value', $meta_value); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -90,7 +92,7 @@ discard block |
||
90 | 92 | if( $answer_obj instanceof EE_Answer ){ |
91 | 93 | if($pretty_answer){ |
92 | 94 | $value = $answer_obj->pretty_value(); |
93 | - }else{ |
|
95 | + } else{ |
|
94 | 96 | $value = $answer_obj->value(); |
95 | 97 | } |
96 | 98 | } |
@@ -148,7 +150,7 @@ discard block |
||
148 | 150 | $value = $registration->attendee()->get_pretty( $field_name ); |
149 | 151 | } |
150 | 152 | //if field name is blank, leave the value as null too |
151 | - }else{ |
|
153 | + } else{ |
|
152 | 154 | $value = $registration->attendee()->get( $field_name ); |
153 | 155 | } |
154 | 156 | } |
@@ -125,14 +125,14 @@ |
||
125 | 125 | public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){ |
126 | 126 | $field_name = NULL; |
127 | 127 | $value = NULL; |
128 | - //backward compat: we still want to find the question's ID |
|
129 | - if( is_numeric( $question_system_id ) ) { |
|
130 | - //find this question's QST_system value |
|
131 | - $question_id = $question_system_id; |
|
132 | - $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
133 | - } else { |
|
134 | - $question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ); |
|
135 | - } |
|
128 | + //backward compat: we still want to find the question's ID |
|
129 | + if( is_numeric( $question_system_id ) ) { |
|
130 | + //find this question's QST_system value |
|
131 | + $question_id = $question_system_id; |
|
132 | + $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
133 | + } else { |
|
134 | + $question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ); |
|
135 | + } |
|
136 | 136 | //only bother checking if the registration has an attendee |
137 | 137 | if( $registration->attendee() instanceof EE_Attendee ) { |
138 | 138 | $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id ); |
@@ -51,18 +51,18 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * constructor |
53 | 53 | */ |
54 | - protected function __construct( $timezone = NULL ){ |
|
55 | - $this->singular_item = __('Answer','event_espresso'); |
|
56 | - $this->plural_item = __('Answers','event_espresso'); |
|
54 | + protected function __construct($timezone = NULL) { |
|
55 | + $this->singular_item = __('Answer', 'event_espresso'); |
|
56 | + $this->plural_item = __('Answers', 'event_espresso'); |
|
57 | 57 | $this->_tables = array( |
58 | 58 | 'Answer'=> new EE_Primary_Table('esp_answer', 'ANS_ID') |
59 | 59 | ); |
60 | 60 | $this->_fields = array( |
61 | 61 | 'Answer'=>array( |
62 | - 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID','event_espresso')), |
|
63 | - 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID','event_espresso'), false, 0, 'Registration'), |
|
64 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'), |
|
65 | - 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value','event_espresso'), false, '') |
|
62 | + 'ANS_ID'=> new EE_Primary_Key_Int_Field('ANS_ID', __('Answer ID', 'event_espresso')), |
|
63 | + 'REG_ID'=>new EE_Foreign_Key_Int_Field('REG_ID', __('Registration ID', 'event_espresso'), false, 0, 'Registration'), |
|
64 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
65 | + 'ANS_value'=>new EE_Maybe_Serialized_Simple_HTML_Field('ANS_value', __('Answer Value', 'event_espresso'), false, '') |
|
66 | 66 | )); |
67 | 67 | $this->_model_relations = array( |
68 | 68 | 'Registration'=>new EE_Belongs_To_Relation(), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | ); |
71 | 71 | $this->_model_chain_to_wp_user = 'Registration.Event'; |
72 | 72 | $this->_caps_slug = 'registrations'; |
73 | - parent::__construct( $timezone ); |
|
73 | + parent::__construct($timezone); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -83,19 +83,19 @@ discard block |
||
83 | 83 | * @param boolean $pretty_answer whether to call 'pretty_value' or just 'value' |
84 | 84 | * @return string |
85 | 85 | */ |
86 | - public function get_answer_value_to_question( EE_Registration $registration, $question_id = NULL,$pretty_answer = FALSE ){ |
|
87 | - $value = $this->get_attendee_property_answer_value( $registration, $question_id, $pretty_answer ); |
|
88 | - if ( $value === NULL ){ |
|
89 | - $answer_obj = $this->get_registration_question_answer_object( $registration, $question_id); |
|
90 | - if( $answer_obj instanceof EE_Answer ){ |
|
91 | - if($pretty_answer){ |
|
86 | + public function get_answer_value_to_question(EE_Registration $registration, $question_id = NULL, $pretty_answer = FALSE) { |
|
87 | + $value = $this->get_attendee_property_answer_value($registration, $question_id, $pretty_answer); |
|
88 | + if ($value === NULL) { |
|
89 | + $answer_obj = $this->get_registration_question_answer_object($registration, $question_id); |
|
90 | + if ($answer_obj instanceof EE_Answer) { |
|
91 | + if ($pretty_answer) { |
|
92 | 92 | $value = $answer_obj->pretty_value(); |
93 | - }else{ |
|
93 | + } else { |
|
94 | 94 | $value = $answer_obj->value(); |
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
98 | - return apply_filters( 'FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id ); |
|
98 | + return apply_filters('FHEE__EEM_Answer__get_answer_value_to_question__answer_value', $value, $registration, $question_id); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * @param int $question_id |
107 | 107 | * @return EE_Answer |
108 | 108 | */ |
109 | - public function get_registration_question_answer_object( EE_Registration $registration, $question_id = NULL){ |
|
110 | - $answer_obj = $this->get_one( array( array( 'QST_ID'=>$question_id, 'REG_ID'=>$registration->ID() ))); |
|
111 | - return apply_filters( 'FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id ); |
|
109 | + public function get_registration_question_answer_object(EE_Registration $registration, $question_id = NULL) { |
|
110 | + $answer_obj = $this->get_one(array(array('QST_ID'=>$question_id, 'REG_ID'=>$registration->ID()))); |
|
111 | + return apply_filters('FHEE__EEM_Answer__get_registration_question_answer_object__answer_obj', $answer_obj, $registration, $question_id); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | |
@@ -122,39 +122,39 @@ discard block |
||
122 | 122 | * @return string|null (if the registration has no attendee, or the question_system_id is not a QST_ID or QST_system for |
123 | 123 | * a question corresponding to an attendee field, returns null) |
124 | 124 | */ |
125 | - public function get_attendee_property_answer_value( EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE ){ |
|
125 | + public function get_attendee_property_answer_value(EE_Registration $registration, $question_system_id = NULL, $pretty_answer = FALSE) { |
|
126 | 126 | $field_name = NULL; |
127 | 127 | $value = NULL; |
128 | 128 | //backward compat: we still want to find the question's ID |
129 | - if( is_numeric( $question_system_id ) ) { |
|
129 | + if (is_numeric($question_system_id)) { |
|
130 | 130 | //find this question's QST_system value |
131 | 131 | $question_id = $question_system_id; |
132 | - $question_system_id = EEM_Question::instance()->get_var( array( array( 'QST_ID' => $question_system_id ) ), 'QST_system' ); |
|
132 | + $question_system_id = EEM_Question::instance()->get_var(array(array('QST_ID' => $question_system_id)), 'QST_system'); |
|
133 | 133 | } else { |
134 | - $question_id = (int) EEM_Question::instance()->get_var( array( array( 'QST_system' => $question_system_id ) ), 'QST_ID' ); |
|
134 | + $question_id = (int) EEM_Question::instance()->get_var(array(array('QST_system' => $question_system_id)), 'QST_ID'); |
|
135 | 135 | } |
136 | 136 | //only bother checking if the registration has an attendee |
137 | - if( $registration->attendee() instanceof EE_Attendee ) { |
|
138 | - $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question( $question_system_id ); |
|
139 | - if( $field_name ) { |
|
140 | - if( $pretty_answer ) { |
|
141 | - if( $field_name === 'STA_ID' ) { |
|
137 | + if ($registration->attendee() instanceof EE_Attendee) { |
|
138 | + $field_name = EEM_Attendee::instance()->get_attendee_field_for_system_question($question_system_id); |
|
139 | + if ($field_name) { |
|
140 | + if ($pretty_answer) { |
|
141 | + if ($field_name === 'STA_ID') { |
|
142 | 142 | $state = $registration->attendee()->state_obj(); |
143 | - $value = $state instanceof EE_State ? $state->name() : sprintf( __('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID() ); |
|
144 | - } else if($field_name === 'CNT_ISO') { |
|
143 | + $value = $state instanceof EE_State ? $state->name() : sprintf(__('Unknown State (%s)', 'event_espresso'), $registration->attendee()->state_ID()); |
|
144 | + } else if ($field_name === 'CNT_ISO') { |
|
145 | 145 | $country = $registration->attendee()->country_obj(); |
146 | - $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"),$registration->attendee()->country_ID()); |
|
146 | + $value = $country instanceof EE_Country ? $country->name() : sprintf(__('Unknown Country (%s)', "event_espresso"), $registration->attendee()->country_ID()); |
|
147 | 147 | } else { |
148 | - $value = $registration->attendee()->get_pretty( $field_name ); |
|
148 | + $value = $registration->attendee()->get_pretty($field_name); |
|
149 | 149 | } |
150 | 150 | //if field name is blank, leave the value as null too |
151 | - }else{ |
|
152 | - $value = $registration->attendee()->get( $field_name ); |
|
151 | + } else { |
|
152 | + $value = $registration->attendee()->get($field_name); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | //if no field was found, leave value blank |
156 | 156 | } |
157 | - return apply_filters( 'FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id ); |
|
157 | + return apply_filters('FHEE__EEM_Answer__get_attendee_question_answer_value__answer_value', $value, $registration, $question_id, $question_system_id); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 |