Completed
Branch master (e6c487)
by
unknown
64:33 queued 56:42
created
reg_steps/attendee_information/attendee_info_single.template.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -6,16 +6,16 @@  discard block
 block discarded – undo
6 6
 <?php if (!is_admin()) : ?>
7 7
     <p id="spco-attendee_information-pg" class="spco-steps-pg small-text drk-grey-text">
8 8
         <?php echo apply_filters(
9
-            'FHEE__registration_page_attendee_information__attendee_information_pg',
10
-            sprintf(
11
-                esc_html__(
12
-                    'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
13
-                    'event_espresso'
14
-                ),
15
-                '<br />',
16
-                '<span class="asterisk">*</span>'
17
-            )
18
-        ); ?>
9
+			'FHEE__registration_page_attendee_information__attendee_information_pg',
10
+			sprintf(
11
+				esc_html__(
12
+					'In order to process your registration, we ask you to provide the following information.%1$sPlease note that all fields marked with an asterisk (%2$s) are required.',
13
+					'event_espresso'
14
+				),
15
+				'<br />',
16
+				'<span class="asterisk">*</span>'
17
+			)
18
+		); ?>
19 19
 </p>
20 20
 <?php endif; ?>
21 21
 
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 $prev_ticket = 0;
26 26
 
27 27
 if (count($registrations) > 0) {
28
-    $ticketID = key($template_args['ticket_count']);
29
-    ?>
28
+	$ticketID = key($template_args['ticket_count']);
29
+	?>
30 30
 
31 31
     <div id="spco-attendee-panel-dv-<?php echo $ticketID; ?>"
32 32
         class="spco-attendee-panel-dv spco-attendee-ticket-<?php echo $ticketID; ?>">
@@ -41,54 +41,54 @@  discard block
 block discarded – undo
41 41
                     <th scope="col" width="" class="jst-left"><?php esc_html_e('Name and Description', 'event_espresso'); ?></th>
42 42
                     <th scope="col" width="7.5%" class="jst-rght">
43 43
                         <?php esc_html_e(
44
-                            'Qty',
45
-                            'event_espresso'
46
-                        ); ?></th>
44
+							'Qty',
45
+							'event_espresso'
46
+						); ?></th>
47 47
                     <th scope="col" width="17.5%" class="jst-rght">
48 48
                         <?php esc_html_e(
49
-                            'Price',
50
-                            'event_espresso'
51
-                        ); ?></th>
49
+							'Price',
50
+							'event_espresso'
51
+						); ?></th>
52 52
                     <th scope="col" width="17.5%" class="jst-rght">
53 53
                         <?php esc_html_e(
54
-                            'Total',
55
-                            'event_espresso'
56
-                        ); ?></th>
54
+							'Total',
55
+							'event_espresso'
56
+						); ?></th>
57 57
                 </tr>
58 58
                 </thead>
59 59
                 <tbody>
60 60
                 <?php
61
-                // Store previous values to avoid duplicated rows.
62
-                $prev_ticket = 0;
63
-                // Display all tickets inside.
64
-                foreach ($registrations as $registration) {
65
-                    if ($registration instanceof EE_Registration) {
66
-                        if ($registration->ticket()->ID() !== $prev_ticket) {
67
-                            echo $ticket_line_item[ $registration->ticket()->ID() ];
68
-                        }
61
+				// Store previous values to avoid duplicated rows.
62
+				$prev_ticket = 0;
63
+				// Display all tickets inside.
64
+				foreach ($registrations as $registration) {
65
+					if ($registration instanceof EE_Registration) {
66
+						if ($registration->ticket()->ID() !== $prev_ticket) {
67
+							echo $ticket_line_item[ $registration->ticket()->ID() ];
68
+						}
69 69
 
70
-                        $prev_ticket = $registration->ticket()->ID();
71
-                    }
72
-                }
73
-                ?>
70
+						$prev_ticket = $registration->ticket()->ID();
71
+					}
72
+				}
73
+				?>
74 74
                 </tbody>
75 75
             </table>
76 76
         </div>
77 77
 
78 78
     <?php
79
-    // Display the forms below the table.
80
-    foreach ($registrations as $registration) {
81
-        if ($registration instanceof EE_Registration) {
82
-            // Attendee Questions.
83
-            $reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
84
-            echo ${$reg_form};
85
-    ?>
79
+	// Display the forms below the table.
80
+	foreach ($registrations as $registration) {
81
+		if ($registration instanceof EE_Registration) {
82
+			// Attendee Questions.
83
+			$reg_form = EE_Template_Layout::get_subform_name($registration->reg_url_link());
84
+			echo ${$reg_form};
85
+	?>
86 86
     </div>
87 87
 <?php
88
-        } // if ( $registration instanceof EE_Registration )
89
-    } // end foreach ( $registrations as $registration )
88
+		} // if ( $registration instanceof EE_Registration )
89
+	} // end foreach ( $registrations as $registration )
90 90
 
91
-    echo $default_hidden_inputs;
91
+	echo $default_hidden_inputs;
92 92
 } // end if ( count( $registrations ) > 0 )
93 93
 
94 94
 ?>
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Event_Shortcodes.lib.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
         // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
137
+        if ( ! $this->_event instanceof EE_Event) {
138 138
             return '';
139 139
         }
140 140
 
@@ -187,11 +187,11 @@  discard block
 block discarded – undo
187 187
                 $image = $this->_event->feature_image_url(array(600, 300));
188 188
                 // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189 189
                 return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
190
+                    ? '<img src="'.$image.'" alt="'
191 191
                       . sprintf(
192 192
                           esc_attr__('%s Feature Image', 'event_espresso'),
193 193
                           $this->_event->get('EVT_name')
194
-                      ) . '" />'
194
+                      ).'" />'
195 195
                     : '';
196 196
                 break;
197 197
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
             // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
252 252
             // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
253 253
             if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
254
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
254
+                || ! empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
255 255
             ) {
256 256
                 return do_shortcode($event_meta);
257 257
             }
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 
270 270
         if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
271 271
             $attrs = $this->_get_shortcode_attrs($shortcode);
272
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
273
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
272
+            $width = empty($attrs['width']) ? '' : ' width="'.$attrs['width'].'"';
273
+            $height = empty($attrs['height']) ? '' : ' height="'.$attrs['height'].'"';
274 274
 
275 275
             // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
276
-            if (! empty($attrs['size'])) {
276
+            if ( ! empty($attrs['size'])) {
277 277
                 $size = explode(',', $attrs['size']);
278 278
                 if (count($size) === 1) {
279 279
                     $size = $size[0];
@@ -285,11 +285,11 @@  discard block
 block discarded – undo
285 285
             $image = $this->_event->feature_image_url($size);
286 286
 
287 287
             return ! empty($image)
288
-                ? '<img src="' . $image . '" alt="'
288
+                ? '<img src="'.$image.'" alt="'
289 289
                   . sprintf(
290 290
                       esc_attr__('%s Feature Image', 'event_espresso'),
291 291
                       $this->_event->get('EVT_name')
292
-                  ) . '"' . $width . $height . '/>'
292
+                  ).'"'.$width.$height.'/>'
293 293
                 : '';
294 294
         }
295 295
 
@@ -308,6 +308,6 @@  discard block
 block discarded – undo
308 308
     {
309 309
         $url = get_permalink($event->ID());
310 310
 
311
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
311
+        return $full_link ? '<a href="'.$url.'">'.$event->get('EVT_name').'</a>' : $url;
312 312
     }
313 313
 }
Please login to merge, or discard this patch.
Indentation   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -19,296 +19,296 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * Will hold the EE_Event if available
24
-     *
25
-     * @var EE_Event
26
-     */
27
-    protected $_event;
28
-
29
-
30
-    public function __construct()
31
-    {
32
-        parent::__construct();
33
-    }
34
-
35
-
36
-    protected function _init_props()
37
-    {
38
-        $this->label = __('Event Shortcodes', 'event_espresso');
39
-        $this->description = __('All shortcodes specific to event related data', 'event_espresso');
40
-        $this->_shortcodes = array(
41
-            '[EVENT_ID]'                              => __(
42
-                'Will be replaced by the event ID of an event',
43
-                'event_espresso'
44
-            ),
45
-            '[EVENT]'                                 => __('The name of the event', 'event_espresso'),
46
-            '[EVENT_NAME]'                            => __(
47
-                "This also can be used for the name of the event",
48
-                'event_espresso'
49
-            ),
50
-            '[EVENT_PHONE]'                           => __(
51
-                'The phone number for the event (usually an info number)',
52
-                'event_espresso'
53
-            ),
54
-            '[EVENT_DESCRIPTION]'                     => __('The description of the event', 'event_espresso'),
55
-            '[EVENT_EXCERPT]'                         => __(
56
-                'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
57
-                'event_espresso'
58
-            ),
59
-            '[EVENT_LINK]'                            => __('A link associated with the event', 'event_espresso'),
60
-            '[EVENT_URL]'                             => __(
61
-                'A link to the event set up on the host site.',
62
-                'event_espresso'
63
-            ),
64
-            '[VIRTUAL_URL]'                           => __(
65
-                'What was used for the "URL of Event" field in the Venue settings',
66
-                'event_espresso'
67
-            ),
68
-            '[VIRTUAL_PHONE]'                         => __(
69
-                'An alternate phone number for the event. Typically used as a "call-in" number',
70
-                'event_espresso'
71
-            ),
72
-            '[EVENT_IMAGE]'                           => __(
73
-                'This will parse to the Feature image for the event.',
74
-                'event_espresso'
75
-            ),
76
-            '[EVENT_IMAGE_*]'                         => sprintf(
77
-                __(
78
-                    'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
79
-                    'event_espresso'
80
-                ),
81
-                '<code>',
82
-                '</code>'
83
-            ),
84
-            '[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
85
-                __(
86
-                    'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
87
-                    'event_espresso'
88
-                ),
89
-                '<code>',
90
-                '</code>'
91
-            ),
92
-            '[EVENT_TOTAL_SPOTS_TAKEN]'               => __(
93
-                'This shortcode will parse to the output the total approved registrations for this event',
94
-                'event_espresso'
95
-            ),
96
-            '[EVENT_FACEBOOK_URL]'                    => __(
97
-                'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
98
-                'event_espresso'
99
-            ),
100
-            '[EVENT_TWITTER_URL]'                     => __(
101
-                'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
102
-                'event_espresso'
103
-            ),
104
-            '[EVENT_META_*]'                          => sprintf(
105
-                __(
106
-                    'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
107
-                    'event_espresso'
108
-                ),
109
-                '<code>',
110
-                '</code>'
111
-            ),
112
-            '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
113
-                'This parses to the url for the registration list table filtered by registrations for this event.',
114
-                'event_espresso'
115
-            ),
116
-        );
117
-    }
118
-
119
-
120
-    protected function _parser($shortcode)
121
-    {
122
-
123
-
124
-        $this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
125
-
126
-        // if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
127
-        if (empty($this->_event)) {
128
-            $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
129
-            $aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
130
-
131
-            $this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
132
-                ? $aee->reg_obj->event() : null;
133
-        }
134
-
135
-
136
-        // If there is no event objecdt by now then get out.
137
-        if (! $this->_event instanceof EE_Event) {
138
-            return '';
139
-        }
140
-
141
-        switch ($shortcode) {
142
-            case '[EVENT_ID]':
143
-                return $this->_event->ID();
144
-                break;
145
-
146
-            case '[EVENT]':
147
-            case '[EVENT_NAME]':
148
-                return $this->_event->get('EVT_name');
149
-                break;
150
-
151
-            case '[EVENT_PHONE]':
152
-                return $this->_event->get('EVT_phone');
153
-                break;
154
-
155
-            case '[EVENT_DESCRIPTION]':
156
-                return $this->_event->get('EVT_desc');
157
-                break;
158
-
159
-            case '[EVENT_EXCERPT]':
160
-                return $this->_event->get('EVT_short_desc');
161
-                break;
162
-
163
-            case '[EVENT_LINK]':
164
-                return $this->_get_event_link($this->_event);
165
-                break;
166
-
167
-            case '[EVENT_URL]':
168
-                return $this->_get_event_link($this->_event, false);
169
-                break;
170
-
171
-            case '[VIRTUAL_URL]':
172
-                $venue = $this->_event->get_first_related('Venue');
173
-                if (empty($venue)) {
174
-                    return '';
175
-                }
176
-                return $venue->get('VNU_virtual_url');
177
-
178
-            case '[VIRTUAL_PHONE]':
179
-                $venue = $this->_event->get_first_related('Venue');
180
-                if (empty($venue)) {
181
-                    return '';
182
-                }
183
-                return $venue->get('VNU_virtual_phone');
184
-                break;
185
-
186
-            case '[EVENT_IMAGE]':
187
-                $image = $this->_event->feature_image_url(array(600, 300));
188
-                // @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189
-                return ! empty($image)
190
-                    ? '<img src="' . $image . '" alt="'
191
-                      . sprintf(
192
-                          esc_attr__('%s Feature Image', 'event_espresso'),
193
-                          $this->_event->get('EVT_name')
194
-                      ) . '" />'
195
-                    : '';
196
-                break;
197
-
198
-            case '[EVENT_FACEBOOK_URL]':
199
-                $facebook_url = $this->_event->get_post_meta('event_facebook', true);
200
-                return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
201
-                    : $facebook_url;
202
-                break;
203
-
204
-            case '[EVENT_TWITTER_URL]':
205
-                $twitter_url = $this->_event->get_post_meta('event_twitter', true);
206
-                return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
207
-                    : $twitter_url;
208
-                break;
209
-
210
-            case '[EVENT_AUTHOR_EMAIL]':
211
-                $author_id = $this->_event->get('EVT_wp_user');
212
-                $user_data = get_userdata((int) $author_id);
213
-                return $user_data->user_email;
214
-                break;
215
-
216
-            case '[EVENT_TOTAL_SPOTS_TAKEN]':
217
-                return EEM_Registration::instance()->count(
218
-                    array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
219
-                    'REG_ID',
220
-                    true
221
-                );
222
-                break;
223
-
224
-            case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
225
-                return EEH_URL::add_query_args_and_nonce(
226
-                    array(
227
-                        'event_id' => $this->_event->ID(),
228
-                        'page'     => 'espresso_registrations',
229
-                        'action'   => 'default',
230
-                    ),
231
-                    admin_url('admin.php'),
232
-                    true
233
-                );
234
-                break;
235
-        }
236
-
237
-        if (strpos($shortcode, '[EVENT_META_*') !== false) {
238
-            // Strip the shortcode itself from $shortcode leaving any attributes set.
239
-            // Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
240
-            $shortcode = str_replace('[EVENT_META_*', '', $shortcode);
241
-            $shortcode = trim(str_replace(']', '', $shortcode));
242
-            // Get any attributes set on this shortcode.
243
-            $attrs = $this->_get_shortcode_attrs($shortcode);
244
-            // The meta_key set on the shortcode should always be the first value in the array.
245
-            $meta_key = $attrs[0];
246
-            // Pull the meta value from the event post.
247
-            $event_meta = $this->_event->get_post_meta($meta_key, true);
248
-            // If we have no event_meta, just return an empty string.
249
-            if (empty($event_meta)) {
250
-                return '';
251
-            }
252
-            // Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
253
-            // Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254
-            if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
255
-                || !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
256
-            ) {
257
-                return do_shortcode($event_meta);
258
-            }
259
-            // Still here? We just need to return the event_meta value as is.
260
-            return $event_meta;
261
-        }
262
-
263
-        if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
264
-            $attrs = $this->_get_shortcode_attrs($shortcode);
265
-            $method = empty($attrs['method']) ? 'current' : $attrs['method'];
266
-            $method = $method === 'current';
267
-            $available = $this->_event->total_available_spaces($method);
268
-            return $available === EE_INF ? '&infin;' : $available;
269
-        }
270
-
271
-        if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
272
-            $attrs = $this->_get_shortcode_attrs($shortcode);
273
-            $width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
274
-            $height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
275
-
276
-            // Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
277
-            if (! empty($attrs['size'])) {
278
-                $size = explode(',', $attrs['size']);
279
-                if (count($size) === 1) {
280
-                    $size = $size[0];
281
-                }
282
-            } else {
283
-                $size = 'thumbnail';
284
-            }
285
-
286
-            $image = $this->_event->feature_image_url($size);
287
-
288
-            return ! empty($image)
289
-                ? '<img src="' . $image . '" alt="'
290
-                  . sprintf(
291
-                      esc_attr__('%s Feature Image', 'event_espresso'),
292
-                      $this->_event->get('EVT_name')
293
-                  ) . '"' . $width . $height . '/>'
294
-                : '';
295
-        }
296
-
297
-        return '';
298
-    }
299
-
300
-
301
-    /**
302
-     * returns the link to the event
303
-     *
304
-     * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
305
-     *                            Otherwise we just return the url of the event.
306
-     * @return string
307
-     */
308
-    private function _get_event_link($event, $full_link = true)
309
-    {
310
-        $url = get_permalink($event->ID());
311
-
312
-        return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
313
-    }
22
+	/**
23
+	 * Will hold the EE_Event if available
24
+	 *
25
+	 * @var EE_Event
26
+	 */
27
+	protected $_event;
28
+
29
+
30
+	public function __construct()
31
+	{
32
+		parent::__construct();
33
+	}
34
+
35
+
36
+	protected function _init_props()
37
+	{
38
+		$this->label = __('Event Shortcodes', 'event_espresso');
39
+		$this->description = __('All shortcodes specific to event related data', 'event_espresso');
40
+		$this->_shortcodes = array(
41
+			'[EVENT_ID]'                              => __(
42
+				'Will be replaced by the event ID of an event',
43
+				'event_espresso'
44
+			),
45
+			'[EVENT]'                                 => __('The name of the event', 'event_espresso'),
46
+			'[EVENT_NAME]'                            => __(
47
+				"This also can be used for the name of the event",
48
+				'event_espresso'
49
+			),
50
+			'[EVENT_PHONE]'                           => __(
51
+				'The phone number for the event (usually an info number)',
52
+				'event_espresso'
53
+			),
54
+			'[EVENT_DESCRIPTION]'                     => __('The description of the event', 'event_espresso'),
55
+			'[EVENT_EXCERPT]'                         => __(
56
+				'This gets parsed to the value for the excerpt field in the event or blank if there is no excerpt.',
57
+				'event_espresso'
58
+			),
59
+			'[EVENT_LINK]'                            => __('A link associated with the event', 'event_espresso'),
60
+			'[EVENT_URL]'                             => __(
61
+				'A link to the event set up on the host site.',
62
+				'event_espresso'
63
+			),
64
+			'[VIRTUAL_URL]'                           => __(
65
+				'What was used for the "URL of Event" field in the Venue settings',
66
+				'event_espresso'
67
+			),
68
+			'[VIRTUAL_PHONE]'                         => __(
69
+				'An alternate phone number for the event. Typically used as a "call-in" number',
70
+				'event_espresso'
71
+			),
72
+			'[EVENT_IMAGE]'                           => __(
73
+				'This will parse to the Feature image for the event.',
74
+				'event_espresso'
75
+			),
76
+			'[EVENT_IMAGE_*]'                         => sprintf(
77
+				__(
78
+					'This will parse to the Feature image for the event, %1$ssize%2$s can be set to determine the size of the image loaded by the shortcode. The %1$swidth%2$s and/or %1$sheight%2$s can also be set to determine the width and height of the image when output. By default the shortcode will load the %1$sthumbnail%2$s image size.',
79
+					'event_espresso'
80
+				),
81
+				'<code>',
82
+				'</code>'
83
+			),
84
+			'[EVENT_TOTAL_AVAILABLE_SPACES_*]'        => sprintf(
85
+				__(
86
+					'This will parse to the total available spaces for an event. Calculating total spaces is approximate because it is dependent on the complexity of limits on your event.  There are two methods of calculation (which can be indicated by the %1$smethod%2$s param on the shortcode).  %1$scurrent%2$s which will do a more accurate calculation of total available spaces based on current sales, and %1$sfull%2$s which will be the maximum total available spaces that is on the event in optimal conditions. The shortcode will default to current.',
87
+					'event_espresso'
88
+				),
89
+				'<code>',
90
+				'</code>'
91
+			),
92
+			'[EVENT_TOTAL_SPOTS_TAKEN]'               => __(
93
+				'This shortcode will parse to the output the total approved registrations for this event',
94
+				'event_espresso'
95
+			),
96
+			'[EVENT_FACEBOOK_URL]'                    => __(
97
+				'This will return the Facebook URL for the event if you have it set via custom field in your event, otherwise it will use the Facebook URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_facebook</code> and the value as your facebook url.',
98
+				'event_espresso'
99
+			),
100
+			'[EVENT_TWITTER_URL]'                     => __(
101
+				'This will return the Twitter URL for the event if you have it set via custom field in your event, otherwise it will use the Twitter URL set in "Your Organization Settings". To set the facebook url in your event, add a custom field with the key as <code>event_twitter</code> and the value as your facebook url',
102
+				'event_espresso'
103
+			),
104
+			'[EVENT_META_*]'                          => sprintf(
105
+				__(
106
+					'This is a special dynamic shortcode. After the "*", add the exact name for your custom field, if there is a value set for that custom field within the event then it will be output in place of this shortcode. If you use shortcodes within your custom fields set %1$sdo_shortcode=true%2$s at the end of the shortcode to run the value through the do_shortcode function. ',
107
+					'event_espresso'
108
+				),
109
+				'<code>',
110
+				'</code>'
111
+			),
112
+			'[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]' => __(
113
+				'This parses to the url for the registration list table filtered by registrations for this event.',
114
+				'event_espresso'
115
+			),
116
+		);
117
+	}
118
+
119
+
120
+	protected function _parser($shortcode)
121
+	{
122
+
123
+
124
+		$this->_event = $this->_data instanceof EE_Event ? $this->_data : null;
125
+
126
+		// if no event, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the event from the reg_obj instead.
127
+		if (empty($this->_event)) {
128
+			$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
129
+			$aee = $this->_extra_data instanceof EE_Messages_Addressee ? $this->_extra_data : $aee;
130
+
131
+			$this->_event = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
132
+				? $aee->reg_obj->event() : null;
133
+		}
134
+
135
+
136
+		// If there is no event objecdt by now then get out.
137
+		if (! $this->_event instanceof EE_Event) {
138
+			return '';
139
+		}
140
+
141
+		switch ($shortcode) {
142
+			case '[EVENT_ID]':
143
+				return $this->_event->ID();
144
+				break;
145
+
146
+			case '[EVENT]':
147
+			case '[EVENT_NAME]':
148
+				return $this->_event->get('EVT_name');
149
+				break;
150
+
151
+			case '[EVENT_PHONE]':
152
+				return $this->_event->get('EVT_phone');
153
+				break;
154
+
155
+			case '[EVENT_DESCRIPTION]':
156
+				return $this->_event->get('EVT_desc');
157
+				break;
158
+
159
+			case '[EVENT_EXCERPT]':
160
+				return $this->_event->get('EVT_short_desc');
161
+				break;
162
+
163
+			case '[EVENT_LINK]':
164
+				return $this->_get_event_link($this->_event);
165
+				break;
166
+
167
+			case '[EVENT_URL]':
168
+				return $this->_get_event_link($this->_event, false);
169
+				break;
170
+
171
+			case '[VIRTUAL_URL]':
172
+				$venue = $this->_event->get_first_related('Venue');
173
+				if (empty($venue)) {
174
+					return '';
175
+				}
176
+				return $venue->get('VNU_virtual_url');
177
+
178
+			case '[VIRTUAL_PHONE]':
179
+				$venue = $this->_event->get_first_related('Venue');
180
+				if (empty($venue)) {
181
+					return '';
182
+				}
183
+				return $venue->get('VNU_virtual_phone');
184
+				break;
185
+
186
+			case '[EVENT_IMAGE]':
187
+				$image = $this->_event->feature_image_url(array(600, 300));
188
+				// @todo: eventually we should make this an attribute shortcode so that em can send along what size they want returned.
189
+				return ! empty($image)
190
+					? '<img src="' . $image . '" alt="'
191
+					  . sprintf(
192
+						  esc_attr__('%s Feature Image', 'event_espresso'),
193
+						  $this->_event->get('EVT_name')
194
+					  ) . '" />'
195
+					: '';
196
+				break;
197
+
198
+			case '[EVENT_FACEBOOK_URL]':
199
+				$facebook_url = $this->_event->get_post_meta('event_facebook', true);
200
+				return empty($facebook_url) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
201
+					: $facebook_url;
202
+				break;
203
+
204
+			case '[EVENT_TWITTER_URL]':
205
+				$twitter_url = $this->_event->get_post_meta('event_twitter', true);
206
+				return empty($twitter_url) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
207
+					: $twitter_url;
208
+				break;
209
+
210
+			case '[EVENT_AUTHOR_EMAIL]':
211
+				$author_id = $this->_event->get('EVT_wp_user');
212
+				$user_data = get_userdata((int) $author_id);
213
+				return $user_data->user_email;
214
+				break;
215
+
216
+			case '[EVENT_TOTAL_SPOTS_TAKEN]':
217
+				return EEM_Registration::instance()->count(
218
+					array(array('EVT_ID' => $this->_event->ID(), 'STS_ID' => EEM_Registration::status_id_approved)),
219
+					'REG_ID',
220
+					true
221
+				);
222
+				break;
223
+
224
+			case '[REGISTRATION_LIST_TABLE_FOR_EVENT_URL]':
225
+				return EEH_URL::add_query_args_and_nonce(
226
+					array(
227
+						'event_id' => $this->_event->ID(),
228
+						'page'     => 'espresso_registrations',
229
+						'action'   => 'default',
230
+					),
231
+					admin_url('admin.php'),
232
+					true
233
+				);
234
+				break;
235
+		}
236
+
237
+		if (strpos($shortcode, '[EVENT_META_*') !== false) {
238
+			// Strip the shortcode itself from $shortcode leaving any attributes set.
239
+			// Removing the * is correct here as _* is used to indiciate a dynamic shortcode.
240
+			$shortcode = str_replace('[EVENT_META_*', '', $shortcode);
241
+			$shortcode = trim(str_replace(']', '', $shortcode));
242
+			// Get any attributes set on this shortcode.
243
+			$attrs = $this->_get_shortcode_attrs($shortcode);
244
+			// The meta_key set on the shortcode should always be the first value in the array.
245
+			$meta_key = $attrs[0];
246
+			// Pull the meta value from the event post.
247
+			$event_meta = $this->_event->get_post_meta($meta_key, true);
248
+			// If we have no event_meta, just return an empty string.
249
+			if (empty($event_meta)) {
250
+				return '';
251
+			}
252
+			// Add a filter to allow all instances of EVENT_META_* to run through do_shortcode, default to false.
253
+			// Check if a do_shortcode attribute was set to true and if so run $event_meta through that function.
254
+			if (apply_filters('FHEE__EventEspresso_core_libraries_shortcodes_EE_Event_Shortcodes___parser__event_meta_do_shortcode', false)
255
+				|| !empty($attrs['do_shortcode']) && filter_var($attrs['do_shortcode'], FILTER_VALIDATE_BOOLEAN)
256
+			) {
257
+				return do_shortcode($event_meta);
258
+			}
259
+			// Still here? We just need to return the event_meta value as is.
260
+			return $event_meta;
261
+		}
262
+
263
+		if (strpos($shortcode, '[EVENT_TOTAL_AVAILABLE_SPACES_*') !== false) {
264
+			$attrs = $this->_get_shortcode_attrs($shortcode);
265
+			$method = empty($attrs['method']) ? 'current' : $attrs['method'];
266
+			$method = $method === 'current';
267
+			$available = $this->_event->total_available_spaces($method);
268
+			return $available === EE_INF ? '&infin;' : $available;
269
+		}
270
+
271
+		if (strpos($shortcode, '[EVENT_IMAGE_*') !== false) {
272
+			$attrs = $this->_get_shortcode_attrs($shortcode);
273
+			$width = empty($attrs['width']) ? '' : ' width="' . $attrs['width'] . '"';
274
+			$height = empty($attrs['height']) ? '' : ' height="' . $attrs['height'] . '"';
275
+
276
+			// Size may be set to a string such as 'tumbnail' or "width, height" eg - '200,200'
277
+			if (! empty($attrs['size'])) {
278
+				$size = explode(',', $attrs['size']);
279
+				if (count($size) === 1) {
280
+					$size = $size[0];
281
+				}
282
+			} else {
283
+				$size = 'thumbnail';
284
+			}
285
+
286
+			$image = $this->_event->feature_image_url($size);
287
+
288
+			return ! empty($image)
289
+				? '<img src="' . $image . '" alt="'
290
+				  . sprintf(
291
+					  esc_attr__('%s Feature Image', 'event_espresso'),
292
+					  $this->_event->get('EVT_name')
293
+				  ) . '"' . $width . $height . '/>'
294
+				: '';
295
+		}
296
+
297
+		return '';
298
+	}
299
+
300
+
301
+	/**
302
+	 * returns the link to the event
303
+	 *
304
+	 * @param  boolean $full_link if TRUE (default) we return the html for the name of the event linked to the event.
305
+	 *                            Otherwise we just return the url of the event.
306
+	 * @return string
307
+	 */
308
+	private function _get_event_link($event, $full_link = true)
309
+	{
310
+		$url = get_permalink($event->ID());
311
+
312
+		return $full_link ? '<a href="' . $url . '">' . $event->get('EVT_name') . '</a>' : $url;
313
+	}
314 314
 }
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.4.0');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.3.rc.031');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.3.rc.031');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/RegistrationsReport.php 1 patch
Indentation   +516 added lines, -516 removed lines patch added patch discarded remove patch
@@ -31,536 +31,536 @@
 block discarded – undo
31 31
  */
32 32
 class RegistrationsReport extends JobHandlerFile
33 33
 {
34
-    // phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
-    // phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
36
-    /**
37
-     * Performs any necessary setup for starting the job. This is also a good
38
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
39
-     * when continue_job will be called
40
-     *
41
-     * @param JobParameters $job_parameters
42
-     * @throws BatchRequestException
43
-     * @return JobStepResponse
44
-     */
45
-    public function create_job(JobParameters $job_parameters)
46
-    {
47
-        $event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
48
-        if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
49
-            throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
50
-        }
51
-        $filepath = $this->create_file_from_job_with_name(
52
-            $job_parameters->job_id(),
53
-            $this->get_filename($event_id)
54
-        );
55
-        $job_parameters->add_extra_data('filepath', $filepath);
56
-        if ($job_parameters->request_datum('use_filters', false)) {
57
-            $query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
58
-        } else {
59
-            $query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
60
-                array(
61
-                    'OR'                 => array(
62
-                        // don't include registrations from failed or abandoned transactions...
63
-                        'Transaction.STS_ID' => array(
64
-                            'NOT IN',
65
-                            array(
66
-                                EEM_Transaction::failed_status_code,
67
-                                EEM_Transaction::abandoned_status_code,
68
-                            ),
69
-                        ),
70
-                        // unless the registration is approved, in which case include it regardless of transaction status
71
-                        'STS_ID'             => \EEM_Registration::status_id_approved,
72
-                    ),
73
-                    'Ticket.TKT_deleted' => array('IN', array(true, false)),
74
-                ),
75
-                'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
76
-                'force_join' => array('Transaction', 'Ticket', 'Attendee'),
77
-                'caps'       => \EEM_Base::caps_read_admin,
78
-            ), $event_id);
79
-            if ($event_id) {
80
-                $query_params[0]['EVT_ID'] = $event_id;
81
-            } else {
82
-                $query_params['force_join'][] = 'Event';
83
-            }
84
-        }
85
-        if (! isset($query_params['force_join'])) {
86
-            $query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
87
-        }
88
-        $job_parameters->add_extra_data('query_params', $query_params);
89
-        $question_labels = $this->_get_question_labels($query_params);
90
-        $job_parameters->add_extra_data('question_labels', $question_labels);
91
-        $job_parameters->set_job_size(
92
-            \EEM_Registration::instance()->count(
93
-                array_diff_key(
94
-                    $query_params,
95
-                    array_flip(
96
-                        array('limit')
97
-                    )
98
-                )
99
-            )
100
-        );
101
-        // we should also set the header columns
102
-        $csv_data_for_row = $this->get_csv_data_for(
103
-            $event_id,
104
-            0,
105
-            1,
106
-            $job_parameters->extra_datum('question_labels'),
107
-            $job_parameters->extra_datum('query_params')
108
-        );
109
-        EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
110
-        // if we actually processed a row there, record it
111
-        if ($job_parameters->job_size()) {
112
-            $job_parameters->mark_processed(1);
113
-        }
114
-        return new JobStepResponse(
115
-            $job_parameters,
116
-            __('Registrations report started successfully...', 'event_espresso')
117
-        );
118
-    }
34
+	// phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
35
+	// phpcs:disable PSR2.Methods.MethodDeclaration.Underscore
36
+	/**
37
+	 * Performs any necessary setup for starting the job. This is also a good
38
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
39
+	 * when continue_job will be called
40
+	 *
41
+	 * @param JobParameters $job_parameters
42
+	 * @throws BatchRequestException
43
+	 * @return JobStepResponse
44
+	 */
45
+	public function create_job(JobParameters $job_parameters)
46
+	{
47
+		$event_id = intval($job_parameters->request_datum('EVT_ID', '0'));
48
+		if (! \EE_Capabilities::instance()->current_user_can('ee_read_registrations', 'generating_report')) {
49
+			throw new BatchRequestException(__('You do not have permission to view registrations', 'event_espresso'));
50
+		}
51
+		$filepath = $this->create_file_from_job_with_name(
52
+			$job_parameters->job_id(),
53
+			$this->get_filename($event_id)
54
+		);
55
+		$job_parameters->add_extra_data('filepath', $filepath);
56
+		if ($job_parameters->request_datum('use_filters', false)) {
57
+			$query_params = maybe_unserialize(stripslashes($job_parameters->request_datum('filters', array())));
58
+		} else {
59
+			$query_params = apply_filters('FHEE__EE_Export__report_registration_for_event', array(
60
+				array(
61
+					'OR'                 => array(
62
+						// don't include registrations from failed or abandoned transactions...
63
+						'Transaction.STS_ID' => array(
64
+							'NOT IN',
65
+							array(
66
+								EEM_Transaction::failed_status_code,
67
+								EEM_Transaction::abandoned_status_code,
68
+							),
69
+						),
70
+						// unless the registration is approved, in which case include it regardless of transaction status
71
+						'STS_ID'             => \EEM_Registration::status_id_approved,
72
+					),
73
+					'Ticket.TKT_deleted' => array('IN', array(true, false)),
74
+				),
75
+				'order_by'   => array('Transaction.TXN_ID' => 'asc', 'REG_count' => 'asc'),
76
+				'force_join' => array('Transaction', 'Ticket', 'Attendee'),
77
+				'caps'       => \EEM_Base::caps_read_admin,
78
+			), $event_id);
79
+			if ($event_id) {
80
+				$query_params[0]['EVT_ID'] = $event_id;
81
+			} else {
82
+				$query_params['force_join'][] = 'Event';
83
+			}
84
+		}
85
+		if (! isset($query_params['force_join'])) {
86
+			$query_params['force_join'] = array('Event', 'Transaction', 'Ticket', 'Attendee');
87
+		}
88
+		$job_parameters->add_extra_data('query_params', $query_params);
89
+		$question_labels = $this->_get_question_labels($query_params);
90
+		$job_parameters->add_extra_data('question_labels', $question_labels);
91
+		$job_parameters->set_job_size(
92
+			\EEM_Registration::instance()->count(
93
+				array_diff_key(
94
+					$query_params,
95
+					array_flip(
96
+						array('limit')
97
+					)
98
+				)
99
+			)
100
+		);
101
+		// we should also set the header columns
102
+		$csv_data_for_row = $this->get_csv_data_for(
103
+			$event_id,
104
+			0,
105
+			1,
106
+			$job_parameters->extra_datum('question_labels'),
107
+			$job_parameters->extra_datum('query_params')
108
+		);
109
+		EEH_Export::write_data_array_to_csv($filepath, $csv_data_for_row, true);
110
+		// if we actually processed a row there, record it
111
+		if ($job_parameters->job_size()) {
112
+			$job_parameters->mark_processed(1);
113
+		}
114
+		return new JobStepResponse(
115
+			$job_parameters,
116
+			__('Registrations report started successfully...', 'event_espresso')
117
+		);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * Gets the filename
123
-     *
124
-     * @return string
125
-     */
126
-    protected function get_filename()
127
-    {
128
-        return apply_filters(
129
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
130
-            sprintf(
131
-                "event-espresso-registrations-%s.csv",
132
-                str_replace(array(':', ' '), '-', current_time('mysql'))
133
-            )
134
-        );
135
-    }
121
+	/**
122
+	 * Gets the filename
123
+	 *
124
+	 * @return string
125
+	 */
126
+	protected function get_filename()
127
+	{
128
+		return apply_filters(
129
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__get_filename',
130
+			sprintf(
131
+				"event-espresso-registrations-%s.csv",
132
+				str_replace(array(':', ' '), '-', current_time('mysql'))
133
+			)
134
+		);
135
+	}
136 136
 
137 137
 
138
-    /**
139
-     * Gets the questions which are to be used for this report, so they
140
-     * can be remembered for later
141
-     *
142
-     * @param array $registration_query_params
143
-     * @return array question admin labels to be used for this report
144
-     */
145
-    protected function _get_question_labels($registration_query_params)
146
-    {
147
-        $where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
148
-        $question_query_params = array();
149
-        if ($where !== null) {
150
-            $question_query_params = array(
151
-                $this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
152
-            );
153
-        }
154
-        // Make sure it's not a system question
155
-        $question_query_params[0]['OR*not-system-questions'] = [
156
-            'QST_system' => '',
157
-            'QST_system*null' => ['IS_NULL']
158
-        ];
159
-        if (apply_filters(
160
-            'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
161
-            false,
162
-            $registration_query_params
163
-        )) {
164
-            $question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
165
-        }
166
-        $question_query_params['group_by'] = array('QST_ID');
167
-        return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
168
-    }
138
+	/**
139
+	 * Gets the questions which are to be used for this report, so they
140
+	 * can be remembered for later
141
+	 *
142
+	 * @param array $registration_query_params
143
+	 * @return array question admin labels to be used for this report
144
+	 */
145
+	protected function _get_question_labels($registration_query_params)
146
+	{
147
+		$where = isset($registration_query_params[0]) ? $registration_query_params[0] : null;
148
+		$question_query_params = array();
149
+		if ($where !== null) {
150
+			$question_query_params = array(
151
+				$this->_change_registration_where_params_to_question_where_params($registration_query_params[0]),
152
+			);
153
+		}
154
+		// Make sure it's not a system question
155
+		$question_query_params[0]['OR*not-system-questions'] = [
156
+			'QST_system' => '',
157
+			'QST_system*null' => ['IS_NULL']
158
+		];
159
+		if (apply_filters(
160
+			'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport___get_question_labels__only_include_answered_questions',
161
+			false,
162
+			$registration_query_params
163
+		)) {
164
+			$question_query_params[0]['Answer.ANS_ID'] = array('IS_NOT_NULL');
165
+		}
166
+		$question_query_params['group_by'] = array('QST_ID');
167
+		return array_unique(EEM_Question::instance()->get_col($question_query_params, 'QST_admin_label'));
168
+	}
169 169
 
170 170
 
171
-    /**
172
-     * Takes where params meant for registrations and changes them to work for questions
173
-     *
174
-     * @param array $reg_where_params
175
-     * @return array
176
-     */
177
-    protected function _change_registration_where_params_to_question_where_params($reg_where_params)
178
-    {
179
-        $question_where_params = array();
180
-        foreach ($reg_where_params as $key => $val) {
181
-            if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
182
-                $question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
183
-            } else {
184
-                // it's a normal where condition
185
-                $question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
186
-            }
187
-        }
188
-        return $question_where_params;
189
-    }
171
+	/**
172
+	 * Takes where params meant for registrations and changes them to work for questions
173
+	 *
174
+	 * @param array $reg_where_params
175
+	 * @return array
176
+	 */
177
+	protected function _change_registration_where_params_to_question_where_params($reg_where_params)
178
+	{
179
+		$question_where_params = array();
180
+		foreach ($reg_where_params as $key => $val) {
181
+			if (\EEM_Registration::instance()->is_logic_query_param_key($key)) {
182
+				$question_where_params[ $key ] = $this->_change_registration_where_params_to_question_where_params($val);
183
+			} else {
184
+				// it's a normal where condition
185
+				$question_where_params[ 'Question_Group.Event.Registration.' . $key ] = $val;
186
+			}
187
+		}
188
+		return $question_where_params;
189
+	}
190 190
 
191 191
 
192
-    /**
193
-     * Performs another step of the job
194
-     *
195
-     * @param JobParameters $job_parameters
196
-     * @param int           $batch_size
197
-     * @return JobStepResponse
198
-     * @throws \EE_Error
199
-     */
200
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
201
-    {
202
-        if ($job_parameters->units_processed() < $job_parameters->job_size()) {
203
-            $csv_data = $this->get_csv_data_for(
204
-                $job_parameters->request_datum('EVT_ID', '0'),
205
-                $job_parameters->units_processed(),
206
-                $batch_size,
207
-                $job_parameters->extra_datum('question_labels'),
208
-                $job_parameters->extra_datum('query_params')
209
-            );
210
-            EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
211
-            $units_processed = count($csv_data);
212
-        } else {
213
-            $csv_data = array();
214
-            $units_processed = 0;
215
-        }
216
-        $job_parameters->mark_processed($units_processed);
217
-        $extra_response_data = array(
218
-            'file_url' => '',
219
-        );
220
-        if ($units_processed < $batch_size) {
221
-            $job_parameters->set_status(JobParameters::status_complete);
222
-            $extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
223
-        }
192
+	/**
193
+	 * Performs another step of the job
194
+	 *
195
+	 * @param JobParameters $job_parameters
196
+	 * @param int           $batch_size
197
+	 * @return JobStepResponse
198
+	 * @throws \EE_Error
199
+	 */
200
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
201
+	{
202
+		if ($job_parameters->units_processed() < $job_parameters->job_size()) {
203
+			$csv_data = $this->get_csv_data_for(
204
+				$job_parameters->request_datum('EVT_ID', '0'),
205
+				$job_parameters->units_processed(),
206
+				$batch_size,
207
+				$job_parameters->extra_datum('question_labels'),
208
+				$job_parameters->extra_datum('query_params')
209
+			);
210
+			EEH_Export::write_data_array_to_csv($job_parameters->extra_datum('filepath'), $csv_data, false);
211
+			$units_processed = count($csv_data);
212
+		} else {
213
+			$csv_data = array();
214
+			$units_processed = 0;
215
+		}
216
+		$job_parameters->mark_processed($units_processed);
217
+		$extra_response_data = array(
218
+			'file_url' => '',
219
+		);
220
+		if ($units_processed < $batch_size) {
221
+			$job_parameters->set_status(JobParameters::status_complete);
222
+			$extra_response_data['file_url'] = $this->get_url_to_file($job_parameters->extra_datum('filepath'));
223
+		}
224 224
 
225
-        return new JobStepResponse(
226
-            $job_parameters,
227
-            sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
228
-            $extra_response_data
229
-        );
230
-    }
225
+		return new JobStepResponse(
226
+			$job_parameters,
227
+			sprintf(__('Wrote %1$s rows to report CSV file...', 'event_espresso'), count((array) $csv_data)),
228
+			$extra_response_data
229
+		);
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * Gets the csv data for a batch of registrations
235
-     *
236
-     * @param int|null $event_id
237
-     * @param int $offset
238
-     * @param int $limit
239
-     * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
240
-     * @param array $query_params for using where querying the model
241
-     * @return array top-level keys are numeric, next-level keys are column headers
242
-     * @throws \EE_Error
243
-     */
244
-    public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
245
-    {
246
-        $reg_fields_to_include = array(
247
-            'TXN_ID',
248
-            'ATT_ID',
249
-            'REG_ID',
250
-            'REG_date',
251
-            'REG_code',
252
-            'REG_count',
253
-            'REG_final_price',
254
-        );
255
-        $att_fields_to_include = array(
256
-            'ATT_fname',
257
-            'ATT_lname',
258
-            'ATT_email',
259
-            'ATT_address',
260
-            'ATT_address2',
261
-            'ATT_city',
262
-            'STA_ID',
263
-            'CNT_ISO',
264
-            'ATT_zip',
265
-            'ATT_phone',
266
-        );
267
-        $registrations_csv_ready_array = array();
268
-        $reg_model = EE_Registry::instance()->load_model('Registration');
269
-        $query_params['limit'] = array($offset, $limit);
270
-        $registration_rows = $reg_model->get_all_wpdb_results($query_params);
271
-        $registration_ids = array();
272
-        foreach ($registration_rows as $reg_row) {
273
-            $registration_ids[] = intval($reg_row['Registration.REG_ID']);
274
-        }
275
-        foreach ($registration_rows as $reg_row) {
276
-            if (is_array($reg_row)) {
277
-                $reg_csv_array = array();
278
-                if (! $event_id) {
279
-                    // get the event's name and Id
280
-                    $reg_csv_array[ (string) __('Event', 'event_espresso') ] = sprintf(
281
-                        /* translators: 1: event name, 2: event ID */
282
-                        __('%1$s (%2$s)', 'event_espresso'),
283
-                        EEH_Export::prepare_value_from_db_for_display(
284
-                            EEM_Event::instance(),
285
-                            'EVT_name',
286
-                            $reg_row['Event_CPT.post_title']
287
-                        ),
288
-                        $reg_row['Event_CPT.ID']
289
-                    );
290
-                }
291
-                $is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
292
-                /*@var $reg_row EE_Registration */
293
-                foreach ($reg_fields_to_include as $field_name) {
294
-                    $field = $reg_model->field_settings_for($field_name);
295
-                    if ($field_name == 'REG_final_price') {
296
-                        $value = EEH_Export::prepare_value_from_db_for_display(
297
-                            $reg_model,
298
-                            $field_name,
299
-                            $reg_row['Registration.REG_final_price'],
300
-                            'localized_float'
301
-                        );
302
-                    } elseif ($field_name == 'REG_count') {
303
-                        $value = sprintf(
304
-                            /* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */
305
-                            __('%1$s of %2$s', 'event_espresso'),
306
-                            EEH_Export::prepare_value_from_db_for_display(
307
-                                $reg_model,
308
-                                'REG_count',
309
-                                $reg_row['Registration.REG_count']
310
-                            ),
311
-                            EEH_Export::prepare_value_from_db_for_display(
312
-                                $reg_model,
313
-                                'REG_group_size',
314
-                                $reg_row['Registration.REG_group_size']
315
-                            )
316
-                        );
317
-                    } elseif ($field_name == 'REG_date') {
318
-                        $value = EEH_Export::prepare_value_from_db_for_display(
319
-                            $reg_model,
320
-                            $field_name,
321
-                            $reg_row['Registration.REG_date'],
322
-                            'no_html'
323
-                        );
324
-                    } else {
325
-                        $value = EEH_Export::prepare_value_from_db_for_display(
326
-                            $reg_model,
327
-                            $field_name,
328
-                            $reg_row[ $field->get_qualified_column() ]
329
-                        );
330
-                    }
331
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value;
332
-                    if ($field_name == 'REG_final_price') {
333
-                        // add a column named Currency after the final price
334
-                        $reg_csv_array[ (string) __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
335
-                    }
336
-                }
337
-                // get pretty status
338
-                $stati = EEM_Status::instance()->localized_status(
339
-                    array(
340
-                        $reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
341
-                        $reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
342
-                    ),
343
-                    false,
344
-                    'sentence'
345
-                );
346
-                $reg_csv_array[ (string) __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
347
-                // get pretty transaction status
348
-                $reg_csv_array[ (string) __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
349
-                $reg_csv_array[ (string) __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
350
-                    ? EEH_Export::prepare_value_from_db_for_display(
351
-                        EEM_Transaction::instance(),
352
-                        'TXN_total',
353
-                        $reg_row['TransactionTable.TXN_total'],
354
-                        'localized_float'
355
-                    ) : '0.00';
356
-                $reg_csv_array[ (string) __('Amount Paid', 'event_espresso') ] = $is_primary_reg
357
-                    ? EEH_Export::prepare_value_from_db_for_display(
358
-                        EEM_Transaction::instance(),
359
-                        'TXN_paid',
360
-                        $reg_row['TransactionTable.TXN_paid'],
361
-                        'localized_float'
362
-                    ) : '0.00';
363
-                $payment_methods = array();
364
-                $gateway_txn_ids_etc = array();
365
-                $payment_times = array();
366
-                if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
367
-                    $payments_info = EEM_Payment::instance()->get_all_wpdb_results(
368
-                        array(
369
-                            array(
370
-                                'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
371
-                                'STS_ID' => EEM_Payment::status_id_approved,
372
-                            ),
373
-                            'force_join' => array('Payment_Method'),
374
-                        ),
375
-                        ARRAY_A,
376
-                        'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
377
-                    );
378
-                    foreach ($payments_info as $payment_method_and_gateway_txn_id) {
379
-                        $payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
380
-                            ? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
381
-                        $gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
382
-                            ? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
383
-                        $payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
384
-                            ? $payment_method_and_gateway_txn_id['payment_time'] : '';
385
-                    }
386
-                }
387
-                $reg_csv_array[ (string) __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
388
-                $reg_csv_array[ (string) __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
389
-                $reg_csv_array[ (string) __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
390
-                    ',',
391
-                    $gateway_txn_ids_etc
392
-                );
393
-                // get whether or not the user has checked in
394
-                $reg_csv_array[ (string) __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
395
-                    $reg_row['Registration.REG_ID'],
396
-                    'Checkin'
397
-                );
398
-                // get ticket of registration and its price
399
-                $ticket_model = EE_Registry::instance()->load_model('Ticket');
400
-                if ($reg_row['Ticket.TKT_ID']) {
401
-                    $ticket_name = EEH_Export::prepare_value_from_db_for_display(
402
-                        $ticket_model,
403
-                        'TKT_name',
404
-                        $reg_row['Ticket.TKT_name']
405
-                    );
406
-                    $datetimes_strings = array();
407
-                    foreach (EEM_Datetime::instance()->get_all_wpdb_results(
408
-                        array(
409
-                            array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
410
-                            'order_by'                 => array('DTT_EVT_start' => 'ASC'),
411
-                            'default_where_conditions' => 'none',
412
-                        )
413
-                    ) as $datetime) {
414
-                        $datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
415
-                            EEM_Datetime::instance(),
416
-                            'DTT_EVT_start',
417
-                            $datetime['Datetime.DTT_EVT_start']
418
-                        );
419
-                    }
420
-                } else {
421
-                    $ticket_name = __('Unknown', 'event_espresso');
422
-                    $datetimes_strings = array(__('Unknown', 'event_espresso'));
423
-                }
424
-                $reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
425
-                $reg_csv_array[ (string) __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
426
-                // get datetime(s) of registration
427
-                // add attendee columns
428
-                foreach ($att_fields_to_include as $att_field_name) {
429
-                    $field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
430
-                    if ($reg_row['Attendee_CPT.ID']) {
431
-                        if ($att_field_name == 'STA_ID') {
432
-                            $value = EEM_State::instance()->get_var(
433
-                                array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
434
-                                'STA_name'
435
-                            );
436
-                        } elseif ($att_field_name == 'CNT_ISO') {
437
-                            $value = EEM_Country::instance()->get_var(
438
-                                array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
439
-                                'CNT_name'
440
-                            );
441
-                        } else {
442
-                            $value = EEH_Export::prepare_value_from_db_for_display(
443
-                                EEM_Attendee::instance(),
444
-                                $att_field_name,
445
-                                $reg_row[ $field_obj->get_qualified_column() ]
446
-                            );
447
-                        }
448
-                    } else {
449
-                        $value = '';
450
-                    }
451
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value;
452
-                }
453
-                // make sure each registration has the same questions in the same order
454
-                foreach ($question_labels as $question_label) {
455
-                    if (! isset($reg_csv_array[ $question_label ])) {
456
-                        $reg_csv_array[ $question_label ] = null;
457
-                    }
458
-                }
459
-                $answers = EEM_Answer::instance()->get_all_wpdb_results(array(
460
-                    array('REG_ID' => $reg_row['Registration.REG_ID']),
461
-                    'force_join' => array('Question'),
462
-                ));
463
-                // now fill out the questions THEY answered
464
-                foreach ($answers as $answer_row) {
465
-                    if ($answer_row['Question.QST_system']) {
466
-                        // it's an answer to a system question. That was already displayed as part of the attendee
467
-                        // fields, so don't write it out again thanks.
468
-                        continue;
469
-                    }
470
-                    if ($answer_row['Question.QST_ID']) {
471
-                        $question_label = EEH_Export::prepare_value_from_db_for_display(
472
-                            EEM_Question::instance(),
473
-                            'QST_admin_label',
474
-                            $answer_row['Question.QST_admin_label']
475
-                        );
476
-                    } else {
477
-                        $question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
478
-                    }
479
-                    if (isset($answer_row['Question.QST_type'])
480
-                        && $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
481
-                    ) {
482
-                        $reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
483
-                            $answer_row['Answer.ANS_value']
484
-                        );
485
-                    } else {
486
-                        // this isn't for html, so don't show html entities
487
-                        $reg_csv_array[ $question_label ] = html_entity_decode(
488
-                            EEH_Export::prepare_value_from_db_for_display(
489
-                                EEM_Answer::instance(),
490
-                                'ANS_value',
491
-                                $answer_row['Answer.ANS_value']
492
-                            )
493
-                        );
494
-                    }
495
-                }
233
+	/**
234
+	 * Gets the csv data for a batch of registrations
235
+	 *
236
+	 * @param int|null $event_id
237
+	 * @param int $offset
238
+	 * @param int $limit
239
+	 * @param array $question_labels the IDs for all the questions which were answered by someone in this selection
240
+	 * @param array $query_params for using where querying the model
241
+	 * @return array top-level keys are numeric, next-level keys are column headers
242
+	 * @throws \EE_Error
243
+	 */
244
+	public function get_csv_data_for($event_id, $offset, $limit, $question_labels, $query_params)
245
+	{
246
+		$reg_fields_to_include = array(
247
+			'TXN_ID',
248
+			'ATT_ID',
249
+			'REG_ID',
250
+			'REG_date',
251
+			'REG_code',
252
+			'REG_count',
253
+			'REG_final_price',
254
+		);
255
+		$att_fields_to_include = array(
256
+			'ATT_fname',
257
+			'ATT_lname',
258
+			'ATT_email',
259
+			'ATT_address',
260
+			'ATT_address2',
261
+			'ATT_city',
262
+			'STA_ID',
263
+			'CNT_ISO',
264
+			'ATT_zip',
265
+			'ATT_phone',
266
+		);
267
+		$registrations_csv_ready_array = array();
268
+		$reg_model = EE_Registry::instance()->load_model('Registration');
269
+		$query_params['limit'] = array($offset, $limit);
270
+		$registration_rows = $reg_model->get_all_wpdb_results($query_params);
271
+		$registration_ids = array();
272
+		foreach ($registration_rows as $reg_row) {
273
+			$registration_ids[] = intval($reg_row['Registration.REG_ID']);
274
+		}
275
+		foreach ($registration_rows as $reg_row) {
276
+			if (is_array($reg_row)) {
277
+				$reg_csv_array = array();
278
+				if (! $event_id) {
279
+					// get the event's name and Id
280
+					$reg_csv_array[ (string) __('Event', 'event_espresso') ] = sprintf(
281
+						/* translators: 1: event name, 2: event ID */
282
+						__('%1$s (%2$s)', 'event_espresso'),
283
+						EEH_Export::prepare_value_from_db_for_display(
284
+							EEM_Event::instance(),
285
+							'EVT_name',
286
+							$reg_row['Event_CPT.post_title']
287
+						),
288
+						$reg_row['Event_CPT.ID']
289
+					);
290
+				}
291
+				$is_primary_reg = $reg_row['Registration.REG_count'] == '1' ? true : false;
292
+				/*@var $reg_row EE_Registration */
293
+				foreach ($reg_fields_to_include as $field_name) {
294
+					$field = $reg_model->field_settings_for($field_name);
295
+					if ($field_name == 'REG_final_price') {
296
+						$value = EEH_Export::prepare_value_from_db_for_display(
297
+							$reg_model,
298
+							$field_name,
299
+							$reg_row['Registration.REG_final_price'],
300
+							'localized_float'
301
+						);
302
+					} elseif ($field_name == 'REG_count') {
303
+						$value = sprintf(
304
+							/* translators: 1: number of registration in group (REG_count), 2: registration group size (REG_group_size) */
305
+							__('%1$s of %2$s', 'event_espresso'),
306
+							EEH_Export::prepare_value_from_db_for_display(
307
+								$reg_model,
308
+								'REG_count',
309
+								$reg_row['Registration.REG_count']
310
+							),
311
+							EEH_Export::prepare_value_from_db_for_display(
312
+								$reg_model,
313
+								'REG_group_size',
314
+								$reg_row['Registration.REG_group_size']
315
+							)
316
+						);
317
+					} elseif ($field_name == 'REG_date') {
318
+						$value = EEH_Export::prepare_value_from_db_for_display(
319
+							$reg_model,
320
+							$field_name,
321
+							$reg_row['Registration.REG_date'],
322
+							'no_html'
323
+						);
324
+					} else {
325
+						$value = EEH_Export::prepare_value_from_db_for_display(
326
+							$reg_model,
327
+							$field_name,
328
+							$reg_row[ $field->get_qualified_column() ]
329
+						);
330
+					}
331
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = $value;
332
+					if ($field_name == 'REG_final_price') {
333
+						// add a column named Currency after the final price
334
+						$reg_csv_array[ (string) __("Currency", "event_espresso") ] = \EE_Config::instance()->currency->code;
335
+					}
336
+				}
337
+				// get pretty status
338
+				$stati = EEM_Status::instance()->localized_status(
339
+					array(
340
+						$reg_row['Registration.STS_ID']     => __('unknown', 'event_espresso'),
341
+						$reg_row['TransactionTable.STS_ID'] => __('unknown', 'event_espresso'),
342
+					),
343
+					false,
344
+					'sentence'
345
+				);
346
+				$reg_csv_array[ (string) __("Registration Status", 'event_espresso') ] = $stati[ $reg_row['Registration.STS_ID'] ];
347
+				// get pretty transaction status
348
+				$reg_csv_array[ (string) __("Transaction Status", 'event_espresso') ] = $stati[ $reg_row['TransactionTable.STS_ID'] ];
349
+				$reg_csv_array[ (string) __('Transaction Amount Due', 'event_espresso') ] = $is_primary_reg
350
+					? EEH_Export::prepare_value_from_db_for_display(
351
+						EEM_Transaction::instance(),
352
+						'TXN_total',
353
+						$reg_row['TransactionTable.TXN_total'],
354
+						'localized_float'
355
+					) : '0.00';
356
+				$reg_csv_array[ (string) __('Amount Paid', 'event_espresso') ] = $is_primary_reg
357
+					? EEH_Export::prepare_value_from_db_for_display(
358
+						EEM_Transaction::instance(),
359
+						'TXN_paid',
360
+						$reg_row['TransactionTable.TXN_paid'],
361
+						'localized_float'
362
+					) : '0.00';
363
+				$payment_methods = array();
364
+				$gateway_txn_ids_etc = array();
365
+				$payment_times = array();
366
+				if ($is_primary_reg && $reg_row['TransactionTable.TXN_ID']) {
367
+					$payments_info = EEM_Payment::instance()->get_all_wpdb_results(
368
+						array(
369
+							array(
370
+								'TXN_ID' => $reg_row['TransactionTable.TXN_ID'],
371
+								'STS_ID' => EEM_Payment::status_id_approved,
372
+							),
373
+							'force_join' => array('Payment_Method'),
374
+						),
375
+						ARRAY_A,
376
+						'Payment_Method.PMD_admin_name as name, Payment.PAY_txn_id_chq_nmbr as gateway_txn_id, Payment.PAY_timestamp as payment_time'
377
+					);
378
+					foreach ($payments_info as $payment_method_and_gateway_txn_id) {
379
+						$payment_methods[] = isset($payment_method_and_gateway_txn_id['name'])
380
+							? $payment_method_and_gateway_txn_id['name'] : __('Unknown', 'event_espresso');
381
+						$gateway_txn_ids_etc[] = isset($payment_method_and_gateway_txn_id['gateway_txn_id'])
382
+							? $payment_method_and_gateway_txn_id['gateway_txn_id'] : '';
383
+						$payment_times[] = isset($payment_method_and_gateway_txn_id['payment_time'])
384
+							? $payment_method_and_gateway_txn_id['payment_time'] : '';
385
+					}
386
+				}
387
+				$reg_csv_array[ (string) __('Payment Date(s)', 'event_espresso') ] = implode(',', $payment_times);
388
+				$reg_csv_array[ (string) __('Payment Method(s)', 'event_espresso') ] = implode(",", $payment_methods);
389
+				$reg_csv_array[ (string) __('Gateway Transaction ID(s)', 'event_espresso') ] = implode(
390
+					',',
391
+					$gateway_txn_ids_etc
392
+				);
393
+				// get whether or not the user has checked in
394
+				$reg_csv_array[ (string) __("Check-Ins", "event_espresso") ] = $reg_model->count_related(
395
+					$reg_row['Registration.REG_ID'],
396
+					'Checkin'
397
+				);
398
+				// get ticket of registration and its price
399
+				$ticket_model = EE_Registry::instance()->load_model('Ticket');
400
+				if ($reg_row['Ticket.TKT_ID']) {
401
+					$ticket_name = EEH_Export::prepare_value_from_db_for_display(
402
+						$ticket_model,
403
+						'TKT_name',
404
+						$reg_row['Ticket.TKT_name']
405
+					);
406
+					$datetimes_strings = array();
407
+					foreach (EEM_Datetime::instance()->get_all_wpdb_results(
408
+						array(
409
+							array('Ticket.TKT_ID' => $reg_row['Ticket.TKT_ID']),
410
+							'order_by'                 => array('DTT_EVT_start' => 'ASC'),
411
+							'default_where_conditions' => 'none',
412
+						)
413
+					) as $datetime) {
414
+						$datetimes_strings[] = EEH_Export::prepare_value_from_db_for_display(
415
+							EEM_Datetime::instance(),
416
+							'DTT_EVT_start',
417
+							$datetime['Datetime.DTT_EVT_start']
418
+						);
419
+					}
420
+				} else {
421
+					$ticket_name = __('Unknown', 'event_espresso');
422
+					$datetimes_strings = array(__('Unknown', 'event_espresso'));
423
+				}
424
+				$reg_csv_array[ (string) $ticket_model->field_settings_for('TKT_name')->get_nicename() ] = $ticket_name;
425
+				$reg_csv_array[ (string) __("Datetimes of Ticket", "event_espresso") ] = implode(", ", $datetimes_strings);
426
+				// get datetime(s) of registration
427
+				// add attendee columns
428
+				foreach ($att_fields_to_include as $att_field_name) {
429
+					$field_obj = EEM_Attendee::instance()->field_settings_for($att_field_name);
430
+					if ($reg_row['Attendee_CPT.ID']) {
431
+						if ($att_field_name == 'STA_ID') {
432
+							$value = EEM_State::instance()->get_var(
433
+								array(array('STA_ID' => $reg_row['Attendee_Meta.STA_ID'])),
434
+								'STA_name'
435
+							);
436
+						} elseif ($att_field_name == 'CNT_ISO') {
437
+							$value = EEM_Country::instance()->get_var(
438
+								array(array('CNT_ISO' => $reg_row['Attendee_Meta.CNT_ISO'])),
439
+								'CNT_name'
440
+							);
441
+						} else {
442
+							$value = EEH_Export::prepare_value_from_db_for_display(
443
+								EEM_Attendee::instance(),
444
+								$att_field_name,
445
+								$reg_row[ $field_obj->get_qualified_column() ]
446
+							);
447
+						}
448
+					} else {
449
+						$value = '';
450
+					}
451
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field_obj) ] = $value;
452
+				}
453
+				// make sure each registration has the same questions in the same order
454
+				foreach ($question_labels as $question_label) {
455
+					if (! isset($reg_csv_array[ $question_label ])) {
456
+						$reg_csv_array[ $question_label ] = null;
457
+					}
458
+				}
459
+				$answers = EEM_Answer::instance()->get_all_wpdb_results(array(
460
+					array('REG_ID' => $reg_row['Registration.REG_ID']),
461
+					'force_join' => array('Question'),
462
+				));
463
+				// now fill out the questions THEY answered
464
+				foreach ($answers as $answer_row) {
465
+					if ($answer_row['Question.QST_system']) {
466
+						// it's an answer to a system question. That was already displayed as part of the attendee
467
+						// fields, so don't write it out again thanks.
468
+						continue;
469
+					}
470
+					if ($answer_row['Question.QST_ID']) {
471
+						$question_label = EEH_Export::prepare_value_from_db_for_display(
472
+							EEM_Question::instance(),
473
+							'QST_admin_label',
474
+							$answer_row['Question.QST_admin_label']
475
+						);
476
+					} else {
477
+						$question_label = sprintf(__('Question $s', 'event_espresso'), $answer_row['Answer.QST_ID']);
478
+					}
479
+					if (isset($answer_row['Question.QST_type'])
480
+						&& $answer_row['Question.QST_type'] == EEM_Question::QST_type_state
481
+					) {
482
+						$reg_csv_array[ $question_label ] = EEM_State::instance()->get_state_name_by_ID(
483
+							$answer_row['Answer.ANS_value']
484
+						);
485
+					} else {
486
+						// this isn't for html, so don't show html entities
487
+						$reg_csv_array[ $question_label ] = html_entity_decode(
488
+							EEH_Export::prepare_value_from_db_for_display(
489
+								EEM_Answer::instance(),
490
+								'ANS_value',
491
+								$answer_row['Answer.ANS_value']
492
+							)
493
+						);
494
+					}
495
+				}
496 496
 
497
-                /**
498
-                 * Filter to change the contents of each row of the registrations report CSV file.
499
-                 * This can be used to add or remote columns from the CSV file, or change their values.
500
-                 * Note when using: all rows in the CSV should have the same columns.
501
-                 * @param array $reg_csv_array keys are the column names, values are their cell values
502
-                 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
503
-                 */
504
-                $registrations_csv_ready_array[] = apply_filters(
505
-                    'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
506
-                    $reg_csv_array,
507
-                    $reg_row
508
-                );
509
-            }
510
-        }
511
-        // if we couldn't export anything, we want to at least show the column headers
512
-        if (empty($registrations_csv_ready_array)) {
513
-            $reg_csv_array = array();
514
-            $model_and_fields_to_include = array(
515
-                'Registration' => $reg_fields_to_include,
516
-                'Attendee'     => $att_fields_to_include,
517
-            );
518
-            foreach ($model_and_fields_to_include as $model_name => $field_list) {
519
-                $model = EE_Registry::instance()->load_model($model_name);
520
-                foreach ($field_list as $field_name) {
521
-                    $field = $model->field_settings_for($field_name);
522
-                    $reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
523
-                }
524
-            }
525
-            $registrations_csv_ready_array[] = $reg_csv_array;
526
-        }
527
-        return $registrations_csv_ready_array;
528
-    }
497
+				/**
498
+				 * Filter to change the contents of each row of the registrations report CSV file.
499
+				 * This can be used to add or remote columns from the CSV file, or change their values.
500
+				 * Note when using: all rows in the CSV should have the same columns.
501
+				 * @param array $reg_csv_array keys are the column names, values are their cell values
502
+				 * @param array $reg_row one entry from EEM_Registration::get_all_wpdb_results()
503
+				 */
504
+				$registrations_csv_ready_array[] = apply_filters(
505
+					'FHEE__EventEspressoBatchRequest__JobHandlers__RegistrationsReport__reg_csv_array',
506
+					$reg_csv_array,
507
+					$reg_row
508
+				);
509
+			}
510
+		}
511
+		// if we couldn't export anything, we want to at least show the column headers
512
+		if (empty($registrations_csv_ready_array)) {
513
+			$reg_csv_array = array();
514
+			$model_and_fields_to_include = array(
515
+				'Registration' => $reg_fields_to_include,
516
+				'Attendee'     => $att_fields_to_include,
517
+			);
518
+			foreach ($model_and_fields_to_include as $model_name => $field_list) {
519
+				$model = EE_Registry::instance()->load_model($model_name);
520
+				foreach ($field_list as $field_name) {
521
+					$field = $model->field_settings_for($field_name);
522
+					$reg_csv_array[ EEH_Export::get_column_name_for_field($field) ] = null;
523
+				}
524
+			}
525
+			$registrations_csv_ready_array[] = $reg_csv_array;
526
+		}
527
+		return $registrations_csv_ready_array;
528
+	}
529 529
 
530 530
 
531
-    /**
532
-     * Counts total unit to process
533
-     *
534
-     * @deprecated since 4.9.19
535
-     * @param int|array $event_id
536
-     * @return int
537
-     */
538
-    public function count_units_to_process($event_id)
539
-    {
540
-        // use the legacy filter
541
-        if ($event_id) {
542
-            $query_params[0]['EVT_ID'] = $event_id;
543
-        } else {
544
-            $query_params['force_join'][] = 'Event';
545
-        }
546
-        return \EEM_Registration::instance()->count($query_params);
547
-    }
531
+	/**
532
+	 * Counts total unit to process
533
+	 *
534
+	 * @deprecated since 4.9.19
535
+	 * @param int|array $event_id
536
+	 * @return int
537
+	 */
538
+	public function count_units_to_process($event_id)
539
+	{
540
+		// use the legacy filter
541
+		if ($event_id) {
542
+			$query_params[0]['EVT_ID'] = $event_id;
543
+		} else {
544
+			$query_params['force_join'][] = 'Event';
545
+		}
546
+		return \EEM_Registration::instance()->count($query_params);
547
+	}
548 548
 
549 549
 
550
-    /**
551
-     * Performs any clean-up logic when we know the job is completed.
552
-     * In this case, we delete the temporary file
553
-     *
554
-     * @param JobParameters $job_parameters
555
-     * @return boolean
556
-     */
557
-    public function cleanup_job(JobParameters $job_parameters)
558
-    {
559
-        $this->_file_helper->delete(
560
-            \EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
561
-            true,
562
-            'd'
563
-        );
564
-        return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
565
-    }
550
+	/**
551
+	 * Performs any clean-up logic when we know the job is completed.
552
+	 * In this case, we delete the temporary file
553
+	 *
554
+	 * @param JobParameters $job_parameters
555
+	 * @return boolean
556
+	 */
557
+	public function cleanup_job(JobParameters $job_parameters)
558
+	{
559
+		$this->_file_helper->delete(
560
+			\EEH_File::remove_filename_from_filepath($job_parameters->extra_datum('filepath')),
561
+			true,
562
+			'd'
563
+		);
564
+		return new JobStepResponse($job_parameters, __('Cleaned up temporary file', 'event_espresso'));
565
+	}
566 566
 }
Please login to merge, or discard this patch.