@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | 4 | exit('No direct script access allowed'); |
5 | 5 | } |
6 | 6 | |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @author Brent Christensen |
15 | 15 | * |
16 | 16 | */ |
17 | -class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage{ |
|
17 | +class EE_DMS_4_9_0_Answers_With_No_Registration extends EE_Data_Migration_Script_Stage { |
|
18 | 18 | |
19 | 19 | |
20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @return EE_DMS_4_9_0_Answers_With_No_Registration |
25 | 25 | */ |
26 | 26 | public function __construct() { |
27 | - $this->_pretty_name = __( 'Answer Cleanup', 'event_espresso' ); |
|
27 | + $this->_pretty_name = __('Answer Cleanup', 'event_espresso'); |
|
28 | 28 | parent::__construct(); |
29 | 29 | } |
30 | 30 | |
@@ -48,9 +48,9 @@ discard block |
||
48 | 48 | protected function _migration_step($num_items_to_migrate = 50) { |
49 | 49 | global $wpdb; |
50 | 50 | $wpdb->delete( |
51 | - $wpdb->prefix . 'esp_answer', |
|
52 | - array( 'REG_ID' => 0 ), |
|
53 | - array( '%d' ) |
|
51 | + $wpdb->prefix.'esp_answer', |
|
52 | + array('REG_ID' => 0), |
|
53 | + array('%d') |
|
54 | 54 | ); |
55 | 55 | $this->set_completed(); |
56 | 56 | return 1; |
@@ -92,42 +92,42 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return EEM_Message |
94 | 94 | */ |
95 | - protected function __construct( $timezone = null ) { |
|
96 | - $this->singular_item = __('Message','event_espresso'); |
|
97 | - $this->plural_item = __('Messages','event_espresso'); |
|
95 | + protected function __construct($timezone = null) { |
|
96 | + $this->singular_item = __('Message', 'event_espresso'); |
|
97 | + $this->plural_item = __('Messages', 'event_espresso'); |
|
98 | 98 | |
99 | 99 | //used for token generator |
100 | - EE_Registry::instance()->load_helper( 'URL' ); |
|
100 | + EE_Registry::instance()->load_helper('URL'); |
|
101 | 101 | |
102 | 102 | $this->_tables = array( |
103 | - 'Message'=>new EE_Primary_Table('esp_message','MSG_ID') |
|
103 | + 'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID') |
|
104 | 104 | ); |
105 | 105 | |
106 | 106 | $allowed_priority = array( |
107 | - self::priority_high => __( 'high', 'event_espresso' ), |
|
108 | - self::priority_medium => __( 'medium', 'event_espresso' ), |
|
109 | - self::priority_low => __( 'low', 'event_espresso' ) |
|
107 | + self::priority_high => __('high', 'event_espresso'), |
|
108 | + self::priority_medium => __('medium', 'event_espresso'), |
|
109 | + self::priority_low => __('low', 'event_espresso') |
|
110 | 110 | ); |
111 | 111 | |
112 | 112 | $this->_fields = array( |
113 | 113 | 'Message'=>array( |
114 | - 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')), |
|
115 | - 'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ), |
|
116 | - 'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ), |
|
117 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ), |
|
118 | - 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ), |
|
119 | - 'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ), |
|
120 | - 'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ), |
|
121 | - 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
122 | - 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ), |
|
123 | - 'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ), |
|
124 | - 'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ), |
|
125 | - 'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ), |
|
126 | - 'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ), |
|
127 | - 'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ), |
|
128 | - 'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ), |
|
129 | - 'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ), |
|
130 | - 'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() ) |
|
114 | + 'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')), |
|
115 | + 'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()), |
|
116 | + 'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'), |
|
117 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction. This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'), |
|
118 | + 'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'), |
|
119 | + 'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'), |
|
120 | + 'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false), |
|
121 | + 'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
122 | + 'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')), |
|
123 | + 'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''), |
|
124 | + 'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true), |
|
125 | + 'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true), |
|
126 | + 'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''), |
|
127 | + 'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority), |
|
128 | + 'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'), |
|
129 | + 'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()), |
|
130 | + 'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time()) |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | $this->_model_relations = array( |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'Message_Template_Group' => new EE_Belongs_To_Relation(), |
138 | 138 | 'Transaction' => new EE_Belongs_To_Relation() |
139 | 139 | ); |
140 | - parent::__construct( $timezone ); |
|
140 | + parent::__construct($timezone); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | public function create_default_object() { |
149 | 149 | /** @type EE_Message $message */ |
150 | 150 | $message = parent::create_default_object(); |
151 | - if ( $message instanceof EE_Message ) { |
|
152 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
151 | + if ($message instanceof EE_Message) { |
|
152 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
153 | 153 | } |
154 | 154 | return null; |
155 | 155 | } |
@@ -160,11 +160,11 @@ discard block |
||
160 | 160 | * @param mixed $cols_n_values |
161 | 161 | * @return \EE_Message |
162 | 162 | */ |
163 | - public function instantiate_class_from_array_or_object( $cols_n_values ) { |
|
163 | + public function instantiate_class_from_array_or_object($cols_n_values) { |
|
164 | 164 | /** @type EE_Message $message */ |
165 | - $message = parent::instantiate_class_from_array_or_object( $cols_n_values ); |
|
166 | - if ( $message instanceof EE_Message ) { |
|
167 | - return EE_Message_Factory::set_messenger_and_message_type( $message ); |
|
165 | + $message = parent::instantiate_class_from_array_or_object($cols_n_values); |
|
166 | + if ($message instanceof EE_Message) { |
|
167 | + return EE_Message_Factory::set_messenger_and_message_type($message); |
|
168 | 168 | } |
169 | 169 | return null; |
170 | 170 | } |
@@ -177,13 +177,13 @@ discard block |
||
177 | 177 | * @param string $message_type the message type slug |
178 | 178 | * @return boolean |
179 | 179 | */ |
180 | - public function message_sent_for_attendee( $attendee, $message_type ) { |
|
181 | - $attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee ); |
|
182 | - return $this->exists( array( array( |
|
180 | + public function message_sent_for_attendee($attendee, $message_type) { |
|
181 | + $attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee); |
|
182 | + return $this->exists(array(array( |
|
183 | 183 | 'Attendee.ATT_ID' => $attendee_ID, |
184 | 184 | 'MSG_message_type' => $message_type, |
185 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
186 | - ) ) ); |
|
185 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
186 | + ))); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -195,13 +195,13 @@ discard block |
||
195 | 195 | * @param string $message_type the message type slug |
196 | 196 | * @return boolean |
197 | 197 | */ |
198 | - public function message_sent_for_registration( $registration, $message_type ) { |
|
199 | - $registrationID = EEM_Registration::instance()->ensure_is_ID( $registration ); |
|
200 | - return $this->exists( array( array( |
|
198 | + public function message_sent_for_registration($registration, $message_type) { |
|
199 | + $registrationID = EEM_Registration::instance()->ensure_is_ID($registration); |
|
200 | + return $this->exists(array(array( |
|
201 | 201 | 'Registration.REG_ID' => $registrationID, |
202 | 202 | 'MSG_message_type' => $message_type, |
203 | - 'STS_ID' => array( 'IN', $this->stati_indicating_sent() ) |
|
204 | - ) ) ); |
|
203 | + 'STS_ID' => array('IN', $this->stati_indicating_sent()) |
|
204 | + ))); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * @param string $token |
213 | 213 | * @return EE_Message |
214 | 214 | */ |
215 | - public function get_one_by_token( $token ) { |
|
216 | - return $this->get_one( array( array( |
|
215 | + public function get_one_by_token($token) { |
|
216 | + return $this->get_one(array(array( |
|
217 | 217 | 'MSG_token' => $token |
218 | - ) ) ); |
|
218 | + ))); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * Returns stati that indicate the message HAS been sent |
224 | 224 | * @return array of strings for possible stati |
225 | 225 | */ |
226 | - public function stati_indicating_sent(){ |
|
227 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) ); |
|
226 | + public function stati_indicating_sent() { |
|
227 | + return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent)); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | |
@@ -235,13 +235,13 @@ discard block |
||
235 | 235 | * @return array of strings for possible stati. |
236 | 236 | */ |
237 | 237 | public function stati_indicating_to_send() { |
238 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) ); |
|
238 | + return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | |
242 | 242 | |
243 | 243 | public function stati_indicating_failed_sending() { |
244 | - return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', array( self::status_failed, self::status_retry ) ); |
|
244 | + return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', array(self::status_failed, self::status_retry)); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | // the value, matches the corresponding EEM_Base child reference. |
276 | 276 | $expected_vars = $this->_expected_vars_for_query_inject(); |
277 | 277 | $query_params[0] = array(); |
278 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
279 | - $request_value = EE_Registry::instance()->REQ->get( $request_key ); |
|
280 | - if ( $request_value ) { |
|
278 | + foreach ($expected_vars as $request_key => $model_name) { |
|
279 | + $request_value = EE_Registry::instance()->REQ->get($request_key); |
|
280 | + if ($request_value) { |
|
281 | 281 | //special case |
282 | - switch ( $request_key ) { |
|
282 | + switch ($request_key) { |
|
283 | 283 | case '_REG_ID' : |
284 | 284 | $query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array( |
285 | 285 | 'Transaction.Registration.REG_ID' => $request_value, |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | ); |
292 | 292 | break; |
293 | 293 | default : |
294 | - $query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value; |
|
294 | + $query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value; |
|
295 | 295 | break; |
296 | 296 | } |
297 | 297 | } |
@@ -307,53 +307,53 @@ discard block |
||
307 | 307 | $expected_vars = $this->_expected_vars_for_query_inject(); |
308 | 308 | $pretty_label = ''; |
309 | 309 | $label_parts = array(); |
310 | - foreach ( $expected_vars as $request_key => $model_name ) { |
|
311 | - $model = EE_Registry::instance()->load_model( $model_name ); |
|
312 | - if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) { |
|
313 | - switch ( $request_key ) { |
|
310 | + foreach ($expected_vars as $request_key => $model_name) { |
|
311 | + $model = EE_Registry::instance()->load_model($model_name); |
|
312 | + if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) { |
|
313 | + switch ($request_key) { |
|
314 | 314 | case '_REG_ID' : |
315 | 315 | $label_parts[] = sprintf( |
316 | - esc_html__( 'Registration with the ID: %s', 'event_espresso' ), |
|
316 | + esc_html__('Registration with the ID: %s', 'event_espresso'), |
|
317 | 317 | $model_field_value |
318 | 318 | ); |
319 | 319 | break; |
320 | 320 | case 'ATT_ID' : |
321 | 321 | /** @var EE_Attendee $attendee */ |
322 | - $attendee = $model->get_one_by_ID( $model_field_value ); |
|
322 | + $attendee = $model->get_one_by_ID($model_field_value); |
|
323 | 323 | $label_parts[] = $attendee instanceof EE_Attendee |
324 | - ? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() ) |
|
325 | - : sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value ); |
|
324 | + ? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name()) |
|
325 | + : sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value); |
|
326 | 326 | break; |
327 | 327 | case 'ID' : |
328 | 328 | /** @var EE_WP_User $wpUser */ |
329 | - $wpUser = $model->get_one_by_ID( $model_field_value ); |
|
329 | + $wpUser = $model->get_one_by_ID($model_field_value); |
|
330 | 330 | $label_parts[] = $wpUser instanceof EE_WP_User |
331 | - ? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() ) |
|
332 | - : sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value ); |
|
331 | + ? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name()) |
|
332 | + : sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value); |
|
333 | 333 | break; |
334 | 334 | case 'TXN_ID' : |
335 | 335 | $label_parts[] = sprintf( |
336 | - esc_html__( 'Transaction with the ID: %s', 'event_espresso' ), |
|
336 | + esc_html__('Transaction with the ID: %s', 'event_espresso'), |
|
337 | 337 | $model_field_value |
338 | 338 | ); |
339 | 339 | break; |
340 | 340 | case 'EVT_ID' : |
341 | 341 | /** @var EE_Event $Event */ |
342 | - $Event = $model->get_one_by_ID( $model_field_value ); |
|
342 | + $Event = $model->get_one_by_ID($model_field_value); |
|
343 | 343 | $label_parts[] = $Event instanceof EE_Event |
344 | - ? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() ) |
|
345 | - : sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value ); |
|
344 | + ? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name()) |
|
345 | + : sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value); |
|
346 | 346 | break; |
347 | 347 | } |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | - if ( $label_parts ) { |
|
351 | + if ($label_parts) { |
|
352 | 352 | |
353 | 353 | //prepend to the last element of $label_parts an "and". |
354 | - if ( count( $label_parts ) > 1 ) { |
|
355 | - $label_parts_index_to_prepend = count( $label_parts ) - 1; |
|
356 | - $label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ]; |
|
354 | + if (count($label_parts) > 1) { |
|
355 | + $label_parts_index_to_prepend = count($label_parts) - 1; |
|
356 | + $label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend]; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | $pretty_label .= sprintf( |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | 'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.', |
363 | 363 | 'event_espresso' |
364 | 364 | ), |
365 | - implode( ', ', $label_parts ) |
|
365 | + implode(', ', $label_parts) |
|
366 | 366 | ); |
367 | 367 | } |
368 | 368 | return $pretty_label; |