@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param \EE_Message_Repository $message_repository |
73 | 73 | */ |
74 | - public function __construct( EE_Message_Repository $message_repository ) { |
|
75 | - $this->_batch_count = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 ); |
|
74 | + public function __construct(EE_Message_Repository $message_repository) { |
|
75 | + $this->_batch_count = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50); |
|
76 | 76 | $this->_rate_limit = $this->get_rate_limit(); |
77 | 77 | $this->_message_repository = $message_repository; |
78 | 78 | } |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * use the messenger send method but typically is based on preview data. |
92 | 92 | * @return bool Whether the message was successfully added to the repository or not. |
93 | 93 | */ |
94 | - public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) { |
|
94 | + public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) { |
|
95 | 95 | $data['preview'] = $preview; |
96 | 96 | $data['test_send'] = $test_send; |
97 | - return $this->_message_repository->add( $message, $data ); |
|
97 | + return $this->_message_repository->add($message, $data); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | * @param bool $persist This flag indicates whether to attempt to delete the object from the db as well. |
107 | 107 | * @return bool |
108 | 108 | */ |
109 | - public function remove( EE_Message $message, $persist = false ) { |
|
110 | - if ( $persist && $this->_message_repository->current() !== $message ) { |
|
109 | + public function remove(EE_Message $message, $persist = false) { |
|
110 | + if ($persist && $this->_message_repository->current() !== $message) { |
|
111 | 111 | //get pointer on right message |
112 | - if ( $this->_message_repository->has( $message ) ) { |
|
112 | + if ($this->_message_repository->has($message)) { |
|
113 | 113 | $this->_message_repository->rewind(); |
114 | - while( $this->_message_repository->valid() ) { |
|
115 | - if ( $this->_message_repository->current() === $message ) { |
|
114 | + while ($this->_message_repository->valid()) { |
|
115 | + if ($this->_message_repository->current() === $message) { |
|
116 | 116 | break; |
117 | 117 | } |
118 | 118 | $this->_message_repository->next(); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | } |
124 | - return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message ); |
|
124 | + return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
@@ -161,29 +161,29 @@ discard block |
||
161 | 161 | * @return bool true if successfully retrieved batch, false no batch ready. |
162 | 162 | */ |
163 | 163 | public function get_batch_to_generate() { |
164 | - if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) { |
|
164 | + if ($this->is_locked(EE_Messages_Queue::action_generating)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | 168 | //lock batch generation to prevent race conditions. |
169 | - $this->lock_queue( EE_Messages_Queue::action_generating ); |
|
169 | + $this->lock_queue(EE_Messages_Queue::action_generating); |
|
170 | 170 | |
171 | 171 | $query_args = array( |
172 | 172 | // key 0 = where conditions |
173 | - 0 => array( 'STS_ID' => EEM_Message::status_incomplete ), |
|
173 | + 0 => array('STS_ID' => EEM_Message::status_incomplete), |
|
174 | 174 | 'order_by' => $this->_get_priority_orderby(), |
175 | 175 | 'limit' => $this->_batch_count |
176 | 176 | ); |
177 | - $messages = EEM_Message::instance()->get_all( $query_args ); |
|
177 | + $messages = EEM_Message::instance()->get_all($query_args); |
|
178 | 178 | |
179 | - if ( ! $messages ) { |
|
179 | + if ( ! $messages) { |
|
180 | 180 | return false; //nothing to generate |
181 | 181 | } |
182 | 182 | |
183 | - foreach ( $messages as $message ) { |
|
184 | - if ( $message instanceof EE_Message ) { |
|
183 | + foreach ($messages as $message) { |
|
184 | + if ($message instanceof EE_Message) { |
|
185 | 185 | $data = $message->all_extra_meta_array(); |
186 | - $this->add( $message, $data ); |
|
186 | + $this->add($message, $data); |
|
187 | 187 | } |
188 | 188 | } |
189 | 189 | return true; |
@@ -206,34 +206,34 @@ discard block |
||
206 | 206 | * to assist with notifying user. |
207 | 207 | */ |
208 | 208 | public function get_to_send_batch_and_send() { |
209 | - if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) { |
|
209 | + if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) { |
|
210 | 210 | return false; |
211 | 211 | } |
212 | 212 | |
213 | - $this->lock_queue( EE_Messages_Queue::action_sending ); |
|
213 | + $this->lock_queue(EE_Messages_Queue::action_sending); |
|
214 | 214 | |
215 | 215 | $batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit; |
216 | 216 | |
217 | 217 | $query_args = array( |
218 | 218 | // key 0 = where conditions |
219 | - 0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ), |
|
219 | + 0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())), |
|
220 | 220 | 'order_by' => $this->_get_priority_orderby(), |
221 | 221 | 'limit' => $batch |
222 | 222 | ); |
223 | 223 | |
224 | - $messages_to_send = EEM_Message::instance()->get_all( $query_args ); |
|
224 | + $messages_to_send = EEM_Message::instance()->get_all($query_args); |
|
225 | 225 | |
226 | 226 | |
227 | 227 | //any to send? |
228 | - if ( ! $messages_to_send ) { |
|
229 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
228 | + if ( ! $messages_to_send) { |
|
229 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
233 | 233 | //add to queue. |
234 | - foreach ( $messages_to_send as $message ) { |
|
235 | - if ( $message instanceof EE_Message ) { |
|
236 | - $this->add( $message ); |
|
234 | + foreach ($messages_to_send as $message) { |
|
235 | + if ($message instanceof EE_Message) { |
|
236 | + $this->add($message); |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | $this->execute(); |
242 | 242 | |
243 | 243 | //release lock |
244 | - $this->unlock_queue( EE_Messages_Queue::action_sending ); |
|
244 | + $this->unlock_queue(EE_Messages_Queue::action_sending); |
|
245 | 245 | return true; |
246 | 246 | } |
247 | 247 | |
@@ -253,8 +253,8 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @param string $type The type of queue being locked. |
255 | 255 | */ |
256 | - public function lock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
257 | - set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) ); |
|
256 | + public function lock_queue($type = EE_Messages_Queue::action_generating) { |
|
257 | + set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type)); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @param string $type The type of queue being unlocked. |
267 | 267 | */ |
268 | - public function unlock_queue( $type = EE_Messages_Queue::action_generating ) { |
|
269 | - delete_transient( $this->_get_lock_key( $type ) ); |
|
268 | + public function unlock_queue($type = EE_Messages_Queue::action_generating) { |
|
269 | + delete_transient($this->_get_lock_key($type)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $type The type of lock. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | - protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) { |
|
281 | - return '_ee_lock_' . $type; |
|
280 | + protected function _get_lock_key($type = EE_Messages_Queue::action_generating) { |
|
281 | + return '_ee_lock_'.$type; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $type The type of lock |
290 | 290 | * @return int time to expiry in seconds. |
291 | 291 | */ |
292 | - protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) { |
|
293 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type ); |
|
292 | + protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) { |
|
293 | + return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return int |
309 | 309 | */ |
310 | 310 | protected function _get_rate_limit_expiry() { |
311 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS ); |
|
311 | + return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @return int |
320 | 320 | */ |
321 | 321 | protected function _default_rate_limit() { |
322 | - return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 ); |
|
322 | + return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | * @param string $type The type of lock being checked for. |
346 | 346 | * @return bool |
347 | 347 | */ |
348 | - public function is_locked( $type = EE_Messages_Queue::action_generating ) { |
|
348 | + public function is_locked($type = EE_Messages_Queue::action_generating) { |
|
349 | 349 | /** |
350 | 350 | * This filters the default is_locked behaviour. |
351 | 351 | */ |
352 | 352 | $is_locked = filter_var( |
353 | 353 | apply_filters( |
354 | 354 | 'FHEE__EE_Messages_Queue__is_locked', |
355 | - get_transient( $this->_get_lock_key( $type ) ), |
|
355 | + get_transient($this->_get_lock_key($type)), |
|
356 | 356 | $this |
357 | 357 | ), |
358 | 358 | FILTER_VALIDATE_BOOLEAN |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * Also implemented here because messages processed on the same request should not have any locks applied. |
364 | 364 | */ |
365 | 365 | if ( |
366 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
366 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
367 | 367 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
368 | 368 | ) { |
369 | 369 | $is_locked = false; |
@@ -385,9 +385,9 @@ discard block |
||
385 | 385 | * @return int |
386 | 386 | */ |
387 | 387 | public function get_rate_limit() { |
388 | - if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) { |
|
388 | + if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) { |
|
389 | 389 | $rate_limit = $this->_default_rate_limit(); |
390 | - set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() ); |
|
390 | + set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key()); |
|
391 | 391 | } |
392 | 392 | return $rate_limit; |
393 | 393 | } |
@@ -399,12 +399,12 @@ discard block |
||
399 | 399 | * This updates existing rate limit with the new limit which is the old minus the batch. |
400 | 400 | * @param int $batch_completed This sets the new rate limit based on the given batch that was completed. |
401 | 401 | */ |
402 | - public function set_rate_limit( $batch_completed ) { |
|
402 | + public function set_rate_limit($batch_completed) { |
|
403 | 403 | //first get the most up to date rate limit (in case its expired and reset) |
404 | 404 | $rate_limit = $this->get_rate_limit(); |
405 | 405 | $new_limit = $rate_limit - $batch_completed; |
406 | 406 | //updating the transient option directly to avoid resetting the expiry. |
407 | - update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit ); |
|
407 | + update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit); |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | * @param string $task This indicates what type of request is going to be initiated. |
418 | 418 | * @param int $priority This indicates the priority that triggers initiating the request. |
419 | 419 | */ |
420 | - public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) { |
|
420 | + public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) { |
|
421 | 421 | //determine what status is matched with the priority as part of the trigger conditions. |
422 | 422 | $status = $task == 'generate' |
423 | 423 | ? EEM_Message::status_incomplete |
@@ -437,19 +437,19 @@ discard block |
||
437 | 437 | * the same request. |
438 | 438 | */ |
439 | 439 | if ( |
440 | - apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
440 | + apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
441 | 441 | || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
442 | 442 | ) { |
443 | - $messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
444 | - if ( $messages_processor instanceof EE_Messages_Processor ) { |
|
445 | - return $messages_processor->process_immediately_from_queue( $this ); |
|
443 | + $messages_processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
444 | + if ($messages_processor instanceof EE_Messages_Processor) { |
|
445 | + return $messages_processor->process_immediately_from_queue($this); |
|
446 | 446 | } |
447 | 447 | //if we get here then that means the messages processor couldn't be loaded so messages will just remain |
448 | 448 | //queued for manual triggering by end user. |
449 | 449 | } |
450 | 450 | |
451 | - if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) { |
|
452 | - EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task ); |
|
451 | + if ($this->_message_repository->count_by_priority_and_status($priority, $status)) { |
|
452 | + EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
@@ -474,53 +474,53 @@ discard block |
||
474 | 474 | * Also, if the messenger is an request type messenger (or a preview), |
475 | 475 | * its entirely possible that the messenger will exit before |
476 | 476 | */ |
477 | - public function execute( $save = true, $sending_messenger = null, $by_priority = false ) { |
|
477 | + public function execute($save = true, $sending_messenger = null, $by_priority = false) { |
|
478 | 478 | $messages_sent = 0; |
479 | 479 | $this->_did_hook = array(); |
480 | 480 | $this->_message_repository->rewind(); |
481 | 481 | |
482 | - while ( $this->_message_repository->valid() ) { |
|
482 | + while ($this->_message_repository->valid()) { |
|
483 | 483 | $error_messages = array(); |
484 | 484 | /** @type EE_Message $message */ |
485 | 485 | $message = $this->_message_repository->current(); |
486 | 486 | //only process things that are queued for sending |
487 | - if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) { |
|
487 | + if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) { |
|
488 | 488 | $this->_message_repository->next(); |
489 | 489 | continue; |
490 | 490 | } |
491 | 491 | //if $by_priority is set and does not match then continue; |
492 | - if ( $by_priority && $by_priority != $message->priority() ) { |
|
492 | + if ($by_priority && $by_priority != $message->priority()) { |
|
493 | 493 | $this->_message_repository->next(); |
494 | 494 | continue; |
495 | 495 | } |
496 | 496 | //error checking |
497 | - if ( ! $message->valid_messenger() ) { |
|
497 | + if ( ! $message->valid_messenger()) { |
|
498 | 498 | $error_messages[] = sprintf( |
499 | - __( 'The %s messenger is not active at time of sending.', 'event_espresso' ), |
|
499 | + __('The %s messenger is not active at time of sending.', 'event_espresso'), |
|
500 | 500 | $message->messenger() |
501 | 501 | ); |
502 | 502 | } |
503 | - if ( ! $message->valid_message_type() ) { |
|
503 | + if ( ! $message->valid_message_type()) { |
|
504 | 504 | $error_messages[] = sprintf( |
505 | - __( 'The %s message type is not active at the time of sending.', 'event_espresso' ), |
|
505 | + __('The %s message type is not active at the time of sending.', 'event_espresso'), |
|
506 | 506 | $message->message_type() |
507 | 507 | ); |
508 | 508 | } |
509 | 509 | // if there was supposed to be a sending messenger for this message, but it was invalid/inactive, |
510 | 510 | // then it will instead be an EE_Error object, so let's check for that |
511 | - if ( $sending_messenger instanceof EE_Error ) { |
|
511 | + if ($sending_messenger instanceof EE_Error) { |
|
512 | 512 | $error_messages[] = $sending_messenger->getMessage(); |
513 | 513 | } |
514 | 514 | // if there are no errors, then let's process the message |
515 | - if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) { |
|
515 | + if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) { |
|
516 | 516 | $messages_sent++; |
517 | 517 | } |
518 | - $this->_set_error_message( $message, $error_messages ); |
|
518 | + $this->_set_error_message($message, $error_messages); |
|
519 | 519 | //add modified time |
520 | - $message->set_modified( time() ); |
|
520 | + $message->set_modified(time()); |
|
521 | 521 | $this->_message_repository->next(); |
522 | 522 | } |
523 | - if ( $save ) { |
|
523 | + if ($save) { |
|
524 | 524 | $this->save(); |
525 | 525 | } |
526 | 526 | return $messages_sent; |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | * @param mixed $sending_messenger (optional) |
536 | 536 | * @return bool |
537 | 537 | */ |
538 | - protected function _process_message( EE_Message $message, $sending_messenger = null ) { |
|
538 | + protected function _process_message(EE_Message $message, $sending_messenger = null) { |
|
539 | 539 | // these *should* have been validated in the execute() method above |
540 | 540 | $messenger = $message->messenger_object(); |
541 | 541 | $message_type = $message->message_type_object(); |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | && $messenger instanceof EE_messenger |
546 | 546 | && $sending_messenger->name != $messenger->name |
547 | 547 | ) { |
548 | - $messenger->do_secondary_messenger_hooks( $sending_messenger->name ); |
|
548 | + $messenger->do_secondary_messenger_hooks($sending_messenger->name); |
|
549 | 549 | $messenger = $sending_messenger; |
550 | 550 | } |
551 | 551 | // send using messenger, but double check objects |
552 | - if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) { |
|
552 | + if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) { |
|
553 | 553 | //set hook for message type (but only if not using another messenger to send). |
554 | - if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) { |
|
555 | - $message_type->do_messenger_hooks( $messenger ); |
|
556 | - $this->_did_hook[ $message_type->name ] = 1; |
|
554 | + if ( ! isset($this->_did_hook[$message_type->name])) { |
|
555 | + $message_type->do_messenger_hooks($messenger); |
|
556 | + $this->_did_hook[$message_type->name] = 1; |
|
557 | 557 | } |
558 | 558 | //if preview then use preview method |
559 | 559 | return $this->_message_repository->is_preview() |
560 | - ? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() ) |
|
561 | - : $this->_do_send( $message, $messenger, $message_type ); |
|
560 | + ? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send()) |
|
561 | + : $this->_do_send($message, $messenger, $message_type); |
|
562 | 562 | } |
563 | 563 | return false; |
564 | 564 | } |
@@ -576,12 +576,12 @@ discard block |
||
576 | 576 | * @param array $status Stati to check for in queue |
577 | 577 | * @return int Count of EE_Message's matching the given status. |
578 | 578 | */ |
579 | - public function count_STS_in_queue( $status ) { |
|
579 | + public function count_STS_in_queue($status) { |
|
580 | 580 | $count = 0; |
581 | - $status = is_array( $status ) ? $status : array( $status ); |
|
581 | + $status = is_array($status) ? $status : array($status); |
|
582 | 582 | $this->_message_repository->rewind(); |
583 | - foreach( $this->_message_repository as $message ) { |
|
584 | - if ( in_array( $message->STS_ID(), $status ) ) { |
|
583 | + foreach ($this->_message_repository as $message) { |
|
584 | + if (in_array($message->STS_ID(), $status)) { |
|
585 | 585 | $count++; |
586 | 586 | } |
587 | 587 | } |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | * @param $test_send |
599 | 599 | * @return bool true means all went well, false means, not so much. |
600 | 600 | */ |
601 | - protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) { |
|
602 | - if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) { |
|
603 | - if ( ! $test_send ) { |
|
604 | - $message->set_content( $preview ); |
|
601 | + protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) { |
|
602 | + if ($preview = $messenger->get_preview($message, $message_type, $test_send)) { |
|
603 | + if ( ! $test_send) { |
|
604 | + $message->set_content($preview); |
|
605 | 605 | } |
606 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
606 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
607 | 607 | return true; |
608 | 608 | } else { |
609 | - $message->set_STS_ID( EEM_Message::status_failed ); |
|
609 | + $message->set_STS_ID(EEM_Message::status_failed); |
|
610 | 610 | return false; |
611 | 611 | } |
612 | 612 | } |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | * @param EE_message_type $message_type |
623 | 623 | * @return bool true means all went well, false means, not so much. |
624 | 624 | */ |
625 | - protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) { |
|
626 | - if ( $messenger->send_message( $message, $message_type ) ) { |
|
627 | - $message->set_STS_ID( EEM_Message::status_sent ); |
|
625 | + protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) { |
|
626 | + if ($messenger->send_message($message, $message_type)) { |
|
627 | + $message->set_STS_ID(EEM_Message::status_sent); |
|
628 | 628 | return true; |
629 | 629 | } else { |
630 | - $message->set_STS_ID( EEM_Message::status_retry ); |
|
630 | + $message->set_STS_ID(EEM_Message::status_retry); |
|
631 | 631 | return false; |
632 | 632 | } |
633 | 633 | } |
@@ -641,21 +641,21 @@ discard block |
||
641 | 641 | * @param EE_Message $message |
642 | 642 | * @param array $error_messages the response from the messenger. |
643 | 643 | */ |
644 | - protected function _set_error_message( EE_Message $message, $error_messages ) { |
|
644 | + protected function _set_error_message(EE_Message $message, $error_messages) { |
|
645 | 645 | $error_messages = (array) $error_messages; |
646 | - if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) { |
|
646 | + if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) { |
|
647 | 647 | $notices = EE_Error::has_notices(); |
648 | - $error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' ); |
|
649 | - if ( $notices === 1 ) { |
|
648 | + $error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso'); |
|
649 | + if ($notices === 1) { |
|
650 | 650 | $notices = EE_Error::get_vanilla_notices(); |
651 | - $notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array(); |
|
652 | - $error_messages[] = implode( "\n", $notices['errors'] ); |
|
651 | + $notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array(); |
|
652 | + $error_messages[] = implode("\n", $notices['errors']); |
|
653 | 653 | } |
654 | 654 | } |
655 | - if ( count( $error_messages ) > 0 ) { |
|
656 | - $msg = __( 'Message was not executed successfully.', 'event_espresso' ); |
|
657 | - $msg = $msg . "\n" . implode( "\n", $error_messages ); |
|
658 | - $message->set_error_message( $msg ); |
|
655 | + if (count($error_messages) > 0) { |
|
656 | + $msg = __('Message was not executed successfully.', 'event_espresso'); |
|
657 | + $msg = $msg."\n".implode("\n", $error_messages); |
|
658 | + $message->set_error_message($msg); |
|
659 | 659 | } |
660 | 660 | } |
661 | 661 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public static function instance() { |
60 | 60 | // check if class object is instantiated, and instantiated properly |
61 | - if ( self::$_instance === NULL or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) { |
|
61 | + if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) { |
|
62 | 62 | self::$_instance = new self(); |
63 | 63 | } |
64 | 64 | return self::$_instance; |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | * @access private |
74 | 74 | */ |
75 | 75 | private function __construct() { |
76 | - do_action( 'AHEE__EE_Network_Config__construct__begin',$this ); |
|
76 | + do_action('AHEE__EE_Network_Config__construct__begin', $this); |
|
77 | 77 | //set defaults |
78 | - $this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() ); |
|
78 | + $this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config()); |
|
79 | 79 | $this->addons = array(); |
80 | 80 | |
81 | 81 | $this->_load_config(); |
82 | 82 | |
83 | 83 | // construct__end hook |
84 | - do_action( 'AHEE__EE_Network_Config__construct__end',$this ); |
|
84 | + do_action('AHEE__EE_Network_Config__construct__end', $this); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -94,25 +94,25 @@ discard block |
||
94 | 94 | */ |
95 | 95 | private function _load_config() { |
96 | 96 | //load network config start hook |
97 | - do_action( 'AHEE__EE_Network_Config___load_config__start', $this ); |
|
97 | + do_action('AHEE__EE_Network_Config___load_config__start', $this); |
|
98 | 98 | $config = $this->get_config(); |
99 | - foreach ( $config as $config_prop => $settings ) { |
|
100 | - if ( is_object( $settings ) && property_exists( $this, $config_prop ) ) { |
|
101 | - $this->{$config_prop} = apply_filters( 'FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this ); |
|
102 | - if ( method_exists( $settings, 'populate' ) ) { |
|
99 | + foreach ($config as $config_prop => $settings) { |
|
100 | + if (is_object($settings) && property_exists($this, $config_prop)) { |
|
101 | + $this->{$config_prop} = apply_filters('FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this); |
|
102 | + if (method_exists($settings, 'populate')) { |
|
103 | 103 | $this->{$config_prop}->populate(); |
104 | 104 | } |
105 | - if ( method_exists( $settings, 'do_hooks' ) ) { |
|
105 | + if (method_exists($settings, 'do_hooks')) { |
|
106 | 106 | $this->{$config_prop}->do_hooks(); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | } |
110 | - if ( apply_filters( 'FHEE__EE_Network_Config___load_config__update_network_config', false ) ) { |
|
110 | + if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) { |
|
111 | 111 | $this->update_config(); |
112 | 112 | } |
113 | 113 | |
114 | 114 | //load network config end hook |
115 | - do_action( 'AHEE__EE_Network_Config___load_config__end', $this ); |
|
115 | + do_action('AHEE__EE_Network_Config___load_config__end', $this); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function get_config() { |
128 | 128 | // grab network configuration |
129 | - $CFG = get_site_option( 'ee_network_config', array() ); |
|
130 | - $CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG ); |
|
129 | + $CFG = get_site_option('ee_network_config', array()); |
|
130 | + $CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG); |
|
131 | 131 | return $CFG; |
132 | 132 | } |
133 | 133 | |
@@ -141,32 +141,32 @@ discard block |
||
141 | 141 | * @param bool $add_error |
142 | 142 | * @return bool success |
143 | 143 | */ |
144 | - public function update_config( $add_success = FALSE, $add_error = TRUE ) { |
|
145 | - do_action( 'AHEE__EE_Network_Config__update_config__begin',$this ); |
|
144 | + public function update_config($add_success = FALSE, $add_error = TRUE) { |
|
145 | + do_action('AHEE__EE_Network_Config__update_config__begin', $this); |
|
146 | 146 | |
147 | 147 | //we have to compare existing saved config with config in memory because if there is no difference that means |
148 | 148 | //that the method executed fine but there just was no update. WordPress doesn't distinguish between false because |
149 | 149 | //there were 0 records updated because of no change vs false because some error produced problems with the update. |
150 | - $original = get_site_option( 'ee_network_config' ); |
|
150 | + $original = get_site_option('ee_network_config'); |
|
151 | 151 | |
152 | - if ( $original == $this ) { |
|
152 | + if ($original == $this) { |
|
153 | 153 | return true; |
154 | 154 | } |
155 | 155 | // update |
156 | - $saved = update_site_option( 'ee_network_config', $this ); |
|
156 | + $saved = update_site_option('ee_network_config', $this); |
|
157 | 157 | |
158 | - do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved ); |
|
158 | + do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved); |
|
159 | 159 | // if config remains the same or was updated successfully |
160 | - if ( $saved ) { |
|
161 | - if ( $add_success ) { |
|
162 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' ); |
|
163 | - EE_Error::add_success( $msg ); |
|
160 | + if ($saved) { |
|
161 | + if ($add_success) { |
|
162 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso'); |
|
163 | + EE_Error::add_success($msg); |
|
164 | 164 | } |
165 | 165 | return TRUE; |
166 | 166 | } else { |
167 | - if ( $add_error ) { |
|
168 | - $msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' ); |
|
169 | - EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ ); |
|
167 | + if ($add_error) { |
|
168 | + $msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso'); |
|
169 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
170 | 170 | } |
171 | 171 | return FALSE; |
172 | 172 | } |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | * @return array |
181 | 181 | */ |
182 | 182 | public function __sleep() { |
183 | - return apply_filters( 'FHEE__EE_Network_Config__sleep',array( |
|
183 | + return apply_filters('FHEE__EE_Network_Config__sleep', array( |
|
184 | 184 | 'core', |
185 | - ) ); |
|
185 | + )); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | } //end EE_Network_Config. |
@@ -23,18 +23,18 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function __construct() { |
25 | 25 | //register tasks (and make sure only registered once). |
26 | - if ( ! has_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ) ) ) { |
|
27 | - add_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ), 10 ); |
|
26 | + if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) { |
|
27 | + add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | //register callbacks for scheduled events (but make sure they are set only once). |
31 | - if ( ! has_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation' ) ) ) { |
|
32 | - add_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation') ); |
|
33 | - add_action( 'AHEE__EE_Messages_Scheduler__sending', array( 'EE_Messages_Scheduler', 'batch_sending' ) ); |
|
31 | + if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'))) { |
|
32 | + add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation')); |
|
33 | + add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | //add custom schedules |
37 | - add_filter( 'cron_schedules', array( $this, 'custom_schedules' ) ); |
|
37 | + add_filter('cron_schedules', array($this, 'custom_schedules')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | * Add custom schedules for wp_cron |
45 | 45 | * @param $schedules |
46 | 46 | */ |
47 | - public function custom_schedules( $schedules ) { |
|
47 | + public function custom_schedules($schedules) { |
|
48 | 48 | $schedules['ee_message_cron'] = array( |
49 | 49 | 'interval' => self::message_cron_schedule, |
50 | - 'display' => __( 'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso' ) |
|
50 | + 'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso') |
|
51 | 51 | ); |
52 | 52 | return $schedules; |
53 | 53 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param array $tasks already existing scheduled tasks |
59 | 59 | * @return array |
60 | 60 | */ |
61 | - public function register_scheduled_tasks( $tasks ) { |
|
61 | + public function register_scheduled_tasks($tasks) { |
|
62 | 62 | $tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron'; |
63 | 63 | $tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron'; |
64 | 64 | return $tasks; |
@@ -70,27 +70,27 @@ discard block |
||
70 | 70 | * Note: The EED_Messages module has the handlers for these requests. |
71 | 71 | * @param string $task The task the request is being generated for. |
72 | 72 | */ |
73 | - public static function initiate_scheduled_non_blocking_request( $task ) { |
|
74 | - if ( apply_filters( 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true ) ) { |
|
75 | - $request_url = add_query_arg( |
|
73 | + public static function initiate_scheduled_non_blocking_request($task) { |
|
74 | + if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true)) { |
|
75 | + $request_url = add_query_arg( |
|
76 | 76 | array_merge( |
77 | - array( 'ee' => 'msg_cron_trigger' ), |
|
78 | - EE_Messages_Scheduler::get_request_params( $task ) |
|
77 | + array('ee' => 'msg_cron_trigger'), |
|
78 | + EE_Messages_Scheduler::get_request_params($task) |
|
79 | 79 | ), |
80 | 80 | site_url() |
81 | 81 | ); |
82 | 82 | $request_args = array( |
83 | 83 | 'timeout' => 300, |
84 | - 'blocking' => ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false, |
|
84 | + 'blocking' => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false, |
|
85 | 85 | 'sslverify' => false, |
86 | 86 | 'redirection' => 10, |
87 | 87 | ); |
88 | - $response = wp_remote_get( $request_url, $request_args ); |
|
89 | - if ( is_wp_error( $response ) ) { |
|
90 | - trigger_error( $response->get_error_message() ); |
|
88 | + $response = wp_remote_get($request_url, $request_args); |
|
89 | + if (is_wp_error($response)) { |
|
90 | + trigger_error($response->get_error_message()); |
|
91 | 91 | } |
92 | 92 | } else { |
93 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( $task ); |
|
93 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron($task); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * @param string $task The task the request is for. |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public static function get_request_params( $task ) { |
|
106 | + public static function get_request_params($task) { |
|
107 | 107 | //transient is used for flood control on msg_cron_trigger requests |
108 | - $transient_key = 'ee_trans_' . uniqid( $task ); |
|
109 | - set_transient( $transient_key, 1, 5 * MINUTE_IN_SECONDS ); |
|
108 | + $transient_key = 'ee_trans_'.uniqid($task); |
|
109 | + set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS); |
|
110 | 110 | return array( |
111 | 111 | 'type' => $task, |
112 | 112 | 'key' => $transient_key, |
@@ -120,11 +120,11 @@ discard block |
||
120 | 120 | * This is used to execute an immediate call to the run_cron task performed by EED_Messages |
121 | 121 | * @param string $task The task the request is being generated for. |
122 | 122 | */ |
123 | - public static function initiate_immediate_request_on_cron( $task ) { |
|
124 | - $request_args = EE_Messages_Scheduler::get_request_params( $task ); |
|
123 | + public static function initiate_immediate_request_on_cron($task) { |
|
124 | + $request_args = EE_Messages_Scheduler::get_request_params($task); |
|
125 | 125 | //set those request args in the request so it gets picked up |
126 | - foreach ( $request_args as $request_key => $request_value ) { |
|
127 | - EE_Registry::instance()->REQ->set( $request_key, $request_value ); |
|
126 | + foreach ($request_args as $request_key => $request_value) { |
|
127 | + EE_Registry::instance()->REQ->set($request_key, $request_value); |
|
128 | 128 | } |
129 | 129 | EED_Messages::instance()->run_cron(); |
130 | 130 | } |
@@ -141,10 +141,10 @@ discard block |
||
141 | 141 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
142 | 142 | */ |
143 | 143 | if ( |
144 | - ! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
144 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
145 | 145 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
146 | 146 | ) { |
147 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'generate' ); |
|
147 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate'); |
|
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * @see filter usage in EE_Messages_Queue::initiate_request_by_priority() |
160 | 160 | */ |
161 | 161 | if ( |
162 | - ! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false ) |
|
162 | + ! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false) |
|
163 | 163 | || ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request |
164 | 164 | ) { |
165 | - EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'send' ); |
|
165 | + EE_Messages_Scheduler::initiate_immediate_request_on_cron('send'); |
|
166 | 166 | } |
167 | 167 | } |
168 | 168 |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once ( EE_CLASSES . 'EE_Ticket.class.php' ); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once (EE_CLASSES.'EE_Ticket.class.php'); |
|
26 | 26 | |
27 | 27 | class EEM_Ticket extends EEM_Soft_Delete_Base { |
28 | 28 | |
@@ -35,35 +35,35 @@ discard block |
||
35 | 35 | * @access private |
36 | 36 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
37 | 37 | */ |
38 | - protected function __construct( $timezone ) { |
|
39 | - $this->singular_item = __('Ticket','event_espresso'); |
|
40 | - $this->plural_item = __('Tickets','event_espresso'); |
|
38 | + protected function __construct($timezone) { |
|
39 | + $this->singular_item = __('Ticket', 'event_espresso'); |
|
40 | + $this->plural_item = __('Tickets', 'event_espresso'); |
|
41 | 41 | |
42 | 42 | $this->_tables = array( |
43 | 43 | 'Ticket'=> new EE_Primary_Table('esp_ticket', 'TKT_ID') |
44 | 44 | ); |
45 | 45 | $this->_fields = array( |
46 | 46 | 'Ticket'=>array( |
47 | - 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID','event_espresso')), |
|
48 | - 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID','event_espresso'), false, 0, 'Ticket_Template'), |
|
47 | + 'TKT_ID'=> new EE_Primary_Key_Int_Field('TKT_ID', __('Ticket ID', 'event_espresso')), |
|
48 | + 'TTM_ID'=>new EE_Foreign_Key_Int_Field('TTM_ID', __('Ticket Template ID', 'event_espresso'), false, 0, 'Ticket_Template'), |
|
49 | 49 | 'TKT_name'=>new EE_Plain_Text_Field('TKT_name', __('Ticket Name', 'event_espresso'), false, ''), |
50 | - 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, '' ), |
|
51 | - 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
52 | - 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket','event_espresso'), false, time(), $timezone ), |
|
53 | - 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0 ), |
|
54 | - 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF ), |
|
50 | + 'TKT_description'=>new EE_Post_Content_Field('TKT_description', __('Description of Ticket', 'event_espresso'), false, ''), |
|
51 | + 'TKT_start_date'=>new EE_Datetime_Field('TKT_start_date', __('Start time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
52 | + 'TKT_end_date'=>new EE_Datetime_Field('TKT_end_date', __('End time/date of Ticket', 'event_espresso'), false, time(), $timezone), |
|
53 | + 'TKT_min'=>new EE_Integer_Field('TKT_min', __('Minimum quantity of this ticket that must be purchased', 'event_espresso'), false, 0), |
|
54 | + 'TKT_max'=>new EE_Infinite_Integer_Field('TKT_max', __('Maximum quantity of this ticket that can be purchased in one transaction', 'event_espresso'), false, EE_INF), |
|
55 | 55 | 'TKT_price'=> new EE_Money_Field('TKT_price', 'Final calculated price for ticket', false, 0), |
56 | 56 | 'TKT_sold' => new EE_Integer_Field('TKT_sold', __('Number of this ticket sold', 'event_espresso'), false, 0), |
57 | - 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available','event_espresso'), false, EE_INF), |
|
58 | - 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF ), |
|
59 | - 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false ), |
|
60 | - 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false,false), |
|
61 | - 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false ), |
|
57 | + 'TKT_qty'=>new EE_Infinite_Integer_Field('TKT_qty', __('Quantity of this ticket that is available', 'event_espresso'), false, EE_INF), |
|
58 | + 'TKT_uses'=>new EE_Infinite_Integer_Field('TKT_uses', __('Number of datetimes this ticket can be used at', 'event_espresso'), false, EE_INF), |
|
59 | + 'TKT_required'=>new EE_Boolean_Field('TKT_required', __("Flag indicating whether this ticket must be purchased with a transaction", "event_espresso"), false, false), |
|
60 | + 'TKT_taxable'=>new EE_Boolean_Field('TKT_taxable', __("Flag indicating whether there is tax applied on this ticket", "event_espresso"), false, false), |
|
61 | + 'TKT_is_default'=>new EE_Boolean_Field('TKT_is_default', __('Flag indicating that this ticket is a default ticket', 'event_espresso'), false, false), |
|
62 | 62 | 'TKT_order' => new EE_Integer_Field('TKT_order', __('The order in which the Ticket is displayed in the editor (used for autosaves when the form doesn\'t have the ticket ID yet)', 'event_espresso'), false, 0), |
63 | - 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0 ), |
|
63 | + 'TKT_row' => new EE_Integer_Field('TKT_row', __('How tickets are displayed in the ui', 'event_espresso'), false, 0), |
|
64 | 64 | 'TKT_deleted' => new EE_Trashed_Flag_Field('TKT_deleted', __('Flag indicating if this has been archived or not', 'event_espresso'), false, false), |
65 | - 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE ), |
|
66 | - 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0 ) |
|
65 | + 'TKT_wp_user' => new EE_WP_User_Field('TKT_wp_user', __('Ticket Creator ID', 'event_espresso'), FALSE), |
|
66 | + 'TKT_parent' => new EE_Integer_Field('TKT_parent', __('Indicates what TKT_ID is the parent of this TKT_ID (used in autosaves/revisions)'), true, 0) |
|
67 | 67 | )); |
68 | 68 | $this->_model_relations = array( |
69 | 69 | 'Datetime'=>new EE_HABTM_Relation('Datetime_Ticket'), |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | ); |
76 | 76 | |
77 | 77 | //this model is generally available for reading |
78 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
78 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Default_Public('TKT_is_default', 'Datetime.Event'); |
|
79 | 79 | //account for default tickets in the caps |
80 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
81 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
82 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Default_Protected( 'TKT_is_default', 'Datetime.Event' ); |
|
83 | - parent::__construct( $timezone ); |
|
80 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
81 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
82 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Default_Protected('TKT_is_default', 'Datetime.Event'); |
|
83 | + parent::__construct($timezone); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function get_all_default_tickets() { |
93 | 93 | /** @type EE_Ticket[] $tickets */ |
94 | - $tickets = $this->get_all( array( array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC')) ); |
|
94 | + $tickets = $this->get_all(array(array('TKT_is_default' => 1), 'order_by' => array('TKT_ID' => 'ASC'))); |
|
95 | 95 | //we need to set the start date and end date to today's date and the start of the default dtt |
96 | - return $this->_set_default_dates( $tickets ); |
|
96 | + return $this->_set_default_dates($tickets); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * @param EE_Ticket[] $tickets |
104 | 104 | * @return EE_Ticket[] |
105 | 105 | */ |
106 | - private function _set_default_dates( $tickets ) { |
|
107 | - foreach ( $tickets as $ticket ) { |
|
108 | - $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true) ); |
|
109 | - $ticket->set('TKT_end_date', $this->current_time_for_query( 'TKT_end_date', true ) + (60 * 60 * 24 * 30 ) ); |
|
110 | - $ticket->set_end_time( $this->convert_datetime_for_query( 'TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone ) ); |
|
106 | + private function _set_default_dates($tickets) { |
|
107 | + foreach ($tickets as $ticket) { |
|
108 | + $ticket->set('TKT_start_date', $this->current_time_for_query('TKT_start_date', true)); |
|
109 | + $ticket->set('TKT_end_date', $this->current_time_for_query('TKT_end_date', true) + (60 * 60 * 24 * 30)); |
|
110 | + $ticket->set_end_time($this->convert_datetime_for_query('TKT_end_date', '11:59 pm', 'g:i a', $this->_timezone)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $tickets; |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param array $query_params |
123 | 123 | * @return int |
124 | 124 | */ |
125 | - public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()){ |
|
126 | - return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime( $DTT_ID, $query_params ); |
|
125 | + public function sum_tickets_currently_available_at_datetime($DTT_ID, $query_params = array()) { |
|
126 | + return EEM_Datetime::instance()->sum_tickets_currently_available_at_datetime($DTT_ID, $query_params); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | |
@@ -133,8 +133,8 @@ discard block |
||
133 | 133 | * @param EE_Ticket[] $tickets |
134 | 134 | * @return void |
135 | 135 | */ |
136 | - public function update_tickets_sold($tickets){ |
|
137 | - foreach($tickets as $ticket){ |
|
136 | + public function update_tickets_sold($tickets) { |
|
137 | + foreach ($tickets as $ticket) { |
|
138 | 138 | /* @var $ticket EE_Ticket */ |
139 | 139 | $ticket->update_tickets_sold(); |
140 | 140 | } |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | 2 | exit('No direct script access allowed'); |
3 | 3 | } |
4 | -require_once( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
5 | -require_once( EE_CLASSES . 'EE_Question.class.php' ); |
|
4 | +require_once(EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
5 | +require_once(EE_CLASSES.'EE_Question.class.php'); |
|
6 | 6 | |
7 | 7 | |
8 | 8 | |
@@ -101,52 +101,52 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @param null $timezone |
103 | 103 | */ |
104 | - protected function __construct( $timezone = NULL ) { |
|
105 | - $this->singular_item = __('Question','event_espresso'); |
|
106 | - $this->plural_item = __('Questions','event_espresso'); |
|
107 | - $this->_allowed_question_types=apply_filters( |
|
104 | + protected function __construct($timezone = NULL) { |
|
105 | + $this->singular_item = __('Question', 'event_espresso'); |
|
106 | + $this->plural_item = __('Questions', 'event_espresso'); |
|
107 | + $this->_allowed_question_types = apply_filters( |
|
108 | 108 | 'FHEE__EEM_Question__construct__allowed_question_types', |
109 | 109 | array( |
110 | - EEM_Question::QST_type_text =>__('Text','event_espresso'), |
|
111 | - EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'), |
|
112 | - EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'), |
|
113 | - EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'), |
|
114 | - EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'), |
|
115 | - EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'), |
|
116 | - EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'), |
|
117 | - EEM_Question::QST_type_date =>__('Date Picker','event_espresso'), |
|
118 | - EEM_Question::QST_type_html_textarea => __( 'HTML Textarea', 'event_espresso' ), |
|
119 | - EEM_Question::QST_type_email => __( 'Email', 'event_espresso' ), |
|
120 | - EEM_Question::QST_type_us_phone => __( 'USA - Format Phone', 'event_espresso' ), |
|
121 | - EEM_Question::QST_type_decimal => __( 'Number', 'event_espresso' ), |
|
122 | - EEM_Question::QST_type_int => __( 'Whole Number', 'event_espresso' ), |
|
123 | - EEM_Question::QST_type_url => __( 'URL', 'event_espresso' ), |
|
124 | - EEM_Question::QST_type_year => __( 'Year', 'event_espresso' ), |
|
125 | - EEM_Question::QST_type_multi_select => __( 'Multi Select', 'event_espresso' ) |
|
110 | + EEM_Question::QST_type_text =>__('Text', 'event_espresso'), |
|
111 | + EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'), |
|
112 | + EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'), |
|
113 | + EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'), |
|
114 | + EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'), |
|
115 | + EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'), |
|
116 | + EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'), |
|
117 | + EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso'), |
|
118 | + EEM_Question::QST_type_html_textarea => __('HTML Textarea', 'event_espresso'), |
|
119 | + EEM_Question::QST_type_email => __('Email', 'event_espresso'), |
|
120 | + EEM_Question::QST_type_us_phone => __('USA - Format Phone', 'event_espresso'), |
|
121 | + EEM_Question::QST_type_decimal => __('Number', 'event_espresso'), |
|
122 | + EEM_Question::QST_type_int => __('Whole Number', 'event_espresso'), |
|
123 | + EEM_Question::QST_type_url => __('URL', 'event_espresso'), |
|
124 | + EEM_Question::QST_type_year => __('Year', 'event_espresso'), |
|
125 | + EEM_Question::QST_type_multi_select => __('Multi Select', 'event_espresso') |
|
126 | 126 | ) |
127 | 127 | ); |
128 | 128 | $this->_question_descriptions = apply_filters( |
129 | 129 | 'FHEE__EEM_Question__construct__allowed_question_types', |
130 | 130 | array( |
131 | - EEM_Question::QST_type_text => __( 'A single line text input field', 'event_espresso' ), |
|
132 | - EEM_Question::QST_type_textarea => __( 'A multi line text input field', 'event_espresso' ), |
|
133 | - EEM_Question::QST_type_checkbox => __( 'Allows multiple preset options to be selected', 'event_espresso' ), |
|
134 | - EEM_Question::QST_type_radio => __( 'Allows a single preset option to be selected', 'event_espresso' ), |
|
135 | - EEM_Question::QST_type_dropdown => __( 'A dropdown that allows a single selection', 'event_espresso' ), |
|
136 | - EEM_Question::QST_type_state => __( 'A dropdown that lists states/provinces', 'event_espresso' ), |
|
137 | - EEM_Question::QST_type_country => __( 'A dropdown that lists countries', 'event_espresso' ), |
|
138 | - EEM_Question::QST_type_date => __( 'A popup calendar that allows date selections', 'event_espresso' ), |
|
139 | - EEM_Question::QST_type_html_textarea => __( 'A multi line text input field that allows HTML', 'event_espresso' ), |
|
140 | - EEM_Question::QST_type_email => __( 'A text field that must contain a valid Email address', 'event_espresso' ), |
|
141 | - EEM_Question::QST_type_us_phone => __( 'A text field that must contain a valid US phone number', 'event_espresso' ), |
|
142 | - EEM_Question::QST_type_decimal => __( 'A text field that allows number values with decimals', 'event_espresso' ), |
|
143 | - EEM_Question::QST_type_int => __( 'A text field that only allows whole numbers (no decimals)', 'event_espresso' ), |
|
144 | - EEM_Question::QST_type_url => __( 'A text field that must contain a valid URL', 'event_espresso' ), |
|
145 | - EEM_Question::QST_type_year => __( 'A dropdown that lists the last 100 years', 'event_espresso' ), |
|
146 | - EEM_Question::QST_type_multi_select => __( 'A dropdown that allows multiple selections', 'event_espresso' ) |
|
131 | + EEM_Question::QST_type_text => __('A single line text input field', 'event_espresso'), |
|
132 | + EEM_Question::QST_type_textarea => __('A multi line text input field', 'event_espresso'), |
|
133 | + EEM_Question::QST_type_checkbox => __('Allows multiple preset options to be selected', 'event_espresso'), |
|
134 | + EEM_Question::QST_type_radio => __('Allows a single preset option to be selected', 'event_espresso'), |
|
135 | + EEM_Question::QST_type_dropdown => __('A dropdown that allows a single selection', 'event_espresso'), |
|
136 | + EEM_Question::QST_type_state => __('A dropdown that lists states/provinces', 'event_espresso'), |
|
137 | + EEM_Question::QST_type_country => __('A dropdown that lists countries', 'event_espresso'), |
|
138 | + EEM_Question::QST_type_date => __('A popup calendar that allows date selections', 'event_espresso'), |
|
139 | + EEM_Question::QST_type_html_textarea => __('A multi line text input field that allows HTML', 'event_espresso'), |
|
140 | + EEM_Question::QST_type_email => __('A text field that must contain a valid Email address', 'event_espresso'), |
|
141 | + EEM_Question::QST_type_us_phone => __('A text field that must contain a valid US phone number', 'event_espresso'), |
|
142 | + EEM_Question::QST_type_decimal => __('A text field that allows number values with decimals', 'event_espresso'), |
|
143 | + EEM_Question::QST_type_int => __('A text field that only allows whole numbers (no decimals)', 'event_espresso'), |
|
144 | + EEM_Question::QST_type_url => __('A text field that must contain a valid URL', 'event_espresso'), |
|
145 | + EEM_Question::QST_type_year => __('A dropdown that lists the last 100 years', 'event_espresso'), |
|
146 | + EEM_Question::QST_type_multi_select => __('A dropdown that allows multiple selections', 'event_espresso') |
|
147 | 147 | ) |
148 | 148 | ); |
149 | - $this->_question_type_categories = (array)apply_filters( |
|
149 | + $this->_question_type_categories = (array) apply_filters( |
|
150 | 150 | 'FHEE__EEM_Question__construct__question_type_categories', |
151 | 151 | array( |
152 | 152 | 'text' => array( |
@@ -171,22 +171,22 @@ discard block |
||
171 | 171 | ); |
172 | 172 | |
173 | 173 | $this->_tables = array( |
174 | - 'Question'=>new EE_Primary_Table('esp_question','QST_ID') |
|
174 | + 'Question'=>new EE_Primary_Table('esp_question', 'QST_ID') |
|
175 | 175 | ); |
176 | 176 | $this->_fields = array( |
177 | 177 | 'Question'=>array( |
178 | - 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')), |
|
179 | - 'QST_display_text'=>new EE_Post_Content_Field('QST_display_text', __('Question Text','event_espresso'), true, ''), |
|
180 | - 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''), |
|
181 | - 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), false, '' ), |
|
182 | - 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types), |
|
183 | - 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false), |
|
184 | - 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''), |
|
185 | - 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0), |
|
186 | - 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false), |
|
187 | - 'QST_max' => new EE_Infinite_Integer_Field( 'QST_max', __( 'Max Size', 'event_espresso' ), false, EE_INF ), |
|
188 | - 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ), |
|
189 | - 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false) |
|
178 | + 'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')), |
|
179 | + 'QST_display_text'=>new EE_Post_Content_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''), |
|
180 | + 'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''), |
|
181 | + 'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), false, ''), |
|
182 | + 'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types), |
|
183 | + 'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false), |
|
184 | + 'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''), |
|
185 | + 'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0), |
|
186 | + 'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false), |
|
187 | + 'QST_max' => new EE_Infinite_Integer_Field('QST_max', __('Max Size', 'event_espresso'), false, EE_INF), |
|
188 | + 'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false), |
|
189 | + 'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false) |
|
190 | 190 | ) |
191 | 191 | ); |
192 | 192 | $this->_model_relations = array( |
@@ -198,11 +198,11 @@ discard block |
||
198 | 198 | 'Question_Group_Question'=>new EE_Has_Many_Relation() |
199 | 199 | ); |
200 | 200 | //this model is generally available for reading |
201 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
202 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
203 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
204 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
205 | - parent::__construct( $timezone ); |
|
201 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
202 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
203 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
204 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('QST_system'); |
|
205 | + parent::__construct($timezone); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * but they can be extended |
211 | 211 | * @return string[] |
212 | 212 | */ |
213 | - public function allowed_question_types(){ |
|
213 | + public function allowed_question_types() { |
|
214 | 214 | return $this->_allowed_question_types; |
215 | 215 | } |
216 | 216 | /** |
@@ -218,16 +218,16 @@ discard block |
||
218 | 218 | * @param string $question_type one of EEM_Question::allowed_question_types( |
219 | 219 | * @return string[] like EEM_Question::allowed_question_types() |
220 | 220 | */ |
221 | - public function question_types_in_same_category( $question_type ) { |
|
222 | - $question_types = array( $question_type ); |
|
223 | - foreach( $this->_question_type_categories as $category => $question_types_in_category ) { |
|
224 | - if( in_array( $question_type, $question_types_in_category ) ) { |
|
221 | + public function question_types_in_same_category($question_type) { |
|
222 | + $question_types = array($question_type); |
|
223 | + foreach ($this->_question_type_categories as $category => $question_types_in_category) { |
|
224 | + if (in_array($question_type, $question_types_in_category)) { |
|
225 | 225 | $question_types = $question_types_in_category; |
226 | 226 | break; |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - return array_intersect_key( $this->allowed_question_types(), array_flip( $question_types ) ); |
|
230 | + return array_intersect_key($this->allowed_question_types(), array_flip($question_types)); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -236,11 +236,11 @@ discard block |
||
236 | 236 | * @param string $category one of the top-level keys of EEM_Question::question_type_categories() |
237 | 237 | * @return boolean |
238 | 238 | */ |
239 | - public function question_type_is_in_category( $question_type, $category ) { |
|
240 | - if( ! isset( $this->_question_type_categories[ $category ] ) ) { |
|
239 | + public function question_type_is_in_category($question_type, $category) { |
|
240 | + if ( ! isset($this->_question_type_categories[$category])) { |
|
241 | 241 | return false; |
242 | 242 | } |
243 | - return in_array( $question_type, $this->_question_type_categories[ $category ] ); |
|
243 | + return in_array($question_type, $this->_question_type_categories[$category]); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | * @param string $system_question_group_id QSG_system |
258 | 258 | * @return array of system question names (QST_system) |
259 | 259 | */ |
260 | - public function allowed_system_questions_in_system_question_group( $system_question_group_id ) { |
|
260 | + public function allowed_system_questions_in_system_question_group($system_question_group_id) { |
|
261 | 261 | $question_system_ids = array(); |
262 | - switch( $system_question_group_id ) { |
|
262 | + switch ($system_question_group_id) { |
|
263 | 263 | case EEM_Question_Group::system_personal: |
264 | 264 | $question_system_ids = array( |
265 | 265 | EEM_Attendee::system_question_fname, |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | ); |
281 | 281 | break; |
282 | 282 | } |
283 | - return apply_filters( 'FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id ); |
|
283 | + return apply_filters('FHEE__EEM_Question__system_questions_allowed_in_system_question_group__return', $question_system_ids, $system_question_group_id); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | * @param string $system_question_group_id QSG_system |
290 | 290 | * @return array of system question names (QST_system) |
291 | 291 | */ |
292 | - public function required_system_questions_in_system_question_group( $system_question_group_id ) { |
|
292 | + public function required_system_questions_in_system_question_group($system_question_group_id) { |
|
293 | 293 | $question_system_ids = null; |
294 | - switch( $system_question_group_id ) { |
|
294 | + switch ($system_question_group_id) { |
|
295 | 295 | case EEM_Question_Group::system_personal: |
296 | - $question_system_ids = array( |
|
296 | + $question_system_ids = array( |
|
297 | 297 | EEM_Attendee::system_question_fname, |
298 | 298 | EEM_Attendee::system_question_email, |
299 | 299 | ); |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | default: |
302 | 302 | $question_system_ids = array(); |
303 | 303 | } |
304 | - return apply_filters( 'FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id ); |
|
304 | + return apply_filters('FHEE__EEM_Question__system_questions_required_in_system_question_group', $question_system_ids, $system_question_group_id); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param $QST_system |
313 | 313 | * @return int of QST_ID for the question that corresponds to that QST_system |
314 | 314 | */ |
315 | - public function get_Question_ID_from_system_string( $QST_system ){ |
|
316 | - return $this->get_var( array( array( 'QST_system' => $QST_system ) ) ); |
|
315 | + public function get_Question_ID_from_system_string($QST_system) { |
|
316 | + return $this->get_var(array(array('QST_system' => $QST_system))); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | |
@@ -325,10 +325,10 @@ discard block |
||
325 | 325 | */ |
326 | 326 | public function get_latest_question_order() { |
327 | 327 | $columns_to_select = array( |
328 | - 'max_order' => array("MAX(QST_order)","%d") |
|
328 | + 'max_order' => array("MAX(QST_order)", "%d") |
|
329 | 329 | ); |
330 | - $max = $this->_get_all_wpdb_results( array(), ARRAY_A, $columns_to_select ); |
|
331 | - return isset( $max[0], $max[0]['max_order'] ) ? $max[0]['max_order'] : 0; |
|
330 | + $max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select); |
|
331 | + return isset($max[0], $max[0]['max_order']) ? $max[0]['max_order'] : 0; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | * @param string $system_question_value |
358 | 358 | * @return int|float |
359 | 359 | */ |
360 | - public function absolute_max_for_system_question( $system_question_value ) { |
|
360 | + public function absolute_max_for_system_question($system_question_value) { |
|
361 | 361 | $maxes = $this->system_question_maxes(); |
362 | - if( isset( $maxes[ $system_question_value ] ) ) { |
|
363 | - return $maxes[ $system_question_value ]; |
|
362 | + if (isset($maxes[$system_question_value])) { |
|
363 | + return $maxes[$system_question_value]; |
|
364 | 364 | } else { |
365 | 365 | return EE_INF; |
366 | 366 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * but you want to have an exceptional case where users can directly submit content |
12 | 12 | * for this field, then you should first run the content through `wp_kses( $content, 'post' )` |
13 | 13 | */ |
14 | -class EE_Full_HTML_Field extends EE_Text_Field_Base{ |
|
14 | +class EE_Full_HTML_Field extends EE_Text_Field_Base { |
|
15 | 15 | |
16 | 16 | |
17 | 17 | /** |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * @return string |
22 | 22 | */ |
23 | 23 | function prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema = null) { |
24 | - if($schema =='form_input'){ |
|
24 | + if ($schema == 'form_input') { |
|
25 | 25 | return parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema); |
26 | - }elseif($schema == 'no_wpautop'){ |
|
26 | + }elseif ($schema == 'no_wpautop') { |
|
27 | 27 | return do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema)); |
28 | - }else{ |
|
28 | + } else { |
|
29 | 29 | return wpautop(do_shortcode(parent::prepare_for_pretty_echoing($value_on_field_to_be_outputted, $schema))); |
30 | 30 | } |
31 | 31 | } |
@@ -3,20 +3,20 @@ |
||
3 | 3 | * Field to only allow tags that are normally allowed on post_content: |
4 | 4 | * address,a,abbr,acronym,area,article,aside,b,big,blockquote,br,button,caption,cite,code,col,del,dd,dfn,details,div,dl,dt,em,fieldset,figure,figcaption,font,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,i,img,ins,kbd,label,legend,li,map,mark,menu,nav,p,pre,q,s,samp,span,section,small,strike,strong,sub,summary,sup,table,tbody,td,textarea,tfoot,th,thead,title,tr,tt,u,ul,ol,var |
5 | 5 | */ |
6 | -class EE_Post_Content_Field extends EE_Text_Field_Base{ |
|
6 | +class EE_Post_Content_Field extends EE_Text_Field_Base { |
|
7 | 7 | /** |
8 | 8 | * removes all tags which a WP Post wouldn't allow in its content normally |
9 | 9 | * @param string $value |
10 | 10 | * @return string |
11 | 11 | */ |
12 | 12 | function prepare_for_set($value) { |
13 | - if( ! current_user_can( 'unfiltered_html' ) ) { |
|
14 | - $value = wp_kses("$value",wp_kses_allowed_html( 'post' )); |
|
13 | + if ( ! current_user_can('unfiltered_html')) { |
|
14 | + $value = wp_kses("$value", wp_kses_allowed_html('post')); |
|
15 | 15 | } |
16 | 16 | return parent::prepare_for_set($value); |
17 | 17 | } |
18 | 18 | |
19 | - function prepare_for_set_from_db($value_found_in_db_for_model_object){ |
|
19 | + function prepare_for_set_from_db($value_found_in_db_for_model_object) { |
|
20 | 20 | return $value_found_in_db_for_model_object; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -13,7 +13,7 @@ |
||
13 | 13 | * @param string $value_inputted_for_field_on_model_object |
14 | 14 | * @return string |
15 | 15 | */ |
16 | - function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
16 | + function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
17 | 17 | if ( ! preg_match( |
18 | 18 | '/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\.!#$%&\'*+-\/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}\-\.\d]+)((\.([a-zA-Z\x{0080}-\x{00FF}\x{0100}-\x{017F}\x{0180}-\x{024F}\x{0250}-\x{02AF}\x{0300}-\x{036F}\x{0370}-\x{03FF}\x{0400}-\x{04FF}\x{0500}-\x{052F}\x{0530}-\x{058F}\x{0590}-\x{05FF}\x{0600}-\x{06FF}\x{0700}-\x{074F}\x{0750}-\x{077F}\x{0780}-\x{07BF}\x{07C0}-\x{07FF}\x{0900}-\x{097F}\x{0980}-\x{09FF}\x{0A00}-\x{0A7F}\x{0A80}-\x{0AFF}\x{0B00}-\x{0B7F}\x{0B80}-\x{0BFF}\x{0C00}-\x{0C7F}\x{0C80}-\x{0CFF}\x{0D00}-\x{0D7F}\x{0D80}-\x{0DFF}\x{0E00}-\x{0E7F}\x{0E80}-\x{0EFF}\x{0F00}-\x{0FFF}\x{1000}-\x{109F}\x{10A0}-\x{10FF}\x{1100}-\x{11FF}\x{1200}-\x{137F}\x{1380}-\x{139F}\x{13A0}-\x{13FF}\x{1400}-\x{167F}\x{1680}-\x{169F}\x{16A0}-\x{16FF}\x{1700}-\x{171F}\x{1720}-\x{173F}\x{1740}-\x{175F}\x{1760}-\x{177F}\x{1780}-\x{17FF}\x{1800}-\x{18AF}\x{1900}-\x{194F}\x{1950}-\x{197F}\x{1980}-\x{19DF}\x{19E0}-\x{19FF}\x{1A00}-\x{1A1F}\x{1B00}-\x{1B7F}\x{1D00}-\x{1D7F}\x{1D80}-\x{1DBF}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{1F00}-\x{1FFF}\x{20D0}-\x{20FF}\x{2100}-\x{214F}\x{2C00}-\x{2C5F}\x{2C60}-\x{2C7F}\x{2C80}-\x{2CFF}\x{2D00}-\x{2D2F}\x{2D30}-\x{2D7F}\x{2D80}-\x{2DDF}\x{2F00}-\x{2FDF}\x{2FF0}-\x{2FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{3100}-\x{312F}\x{3130}-\x{318F}\x{3190}-\x{319F}\x{31C0}-\x{31EF}\x{31F0}-\x{31FF}\x{3200}-\x{32FF}\x{3300}-\x{33FF}\x{3400}-\x{4DBF}\x{4DC0}-\x{4DFF}\x{4E00}-\x{9FFF}\x{A000}-\x{A48F}\x{A490}-\x{A4CF}\x{A700}-\x{A71F}\x{A800}-\x{A82F}\x{A840}-\x{A87F}\x{AC00}-\x{D7AF}\x{F900}-\x{FAFF}]){2,63})+)$/u', |
19 | 19 | $value_inputted_for_field_on_model_object |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | * |
22 | 22 | * ------------------------------------------------------------------------ |
23 | 23 | */ |
24 | -require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' ); |
|
25 | -require_once( EE_CLASSES . 'EE_Question_Option.class.php'); |
|
24 | +require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php'); |
|
25 | +require_once(EE_CLASSES.'EE_Question_Option.class.php'); |
|
26 | 26 | |
27 | 27 | |
28 | 28 | class EEM_Question_Option extends EEM_Soft_Delete_Base { |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | // private instance of the Attendee object |
31 | 31 | protected static $_instance = NULL; |
32 | 32 | |
33 | - protected function __construct( $timezone = NULL ) { |
|
34 | - $this->singular_item = __('Question Option','event_espresso'); |
|
35 | - $this->plural_item = __('Question Options','event_espresso'); |
|
33 | + protected function __construct($timezone = NULL) { |
|
34 | + $this->singular_item = __('Question Option', 'event_espresso'); |
|
35 | + $this->plural_item = __('Question Options', 'event_espresso'); |
|
36 | 36 | |
37 | 37 | $this->_tables = array( |
38 | - 'Question_Option'=>new EE_Primary_Table('esp_question_option','QSO_ID') |
|
38 | + 'Question_Option'=>new EE_Primary_Table('esp_question_option', 'QSO_ID') |
|
39 | 39 | ); |
40 | 40 | $this->_fields = array( |
41 | 41 | 'Question_Option'=>array( |
42 | - 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID','event_espresso')), |
|
43 | - 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID','event_espresso'), false, 0, 'Question'), |
|
44 | - 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"),false,''), |
|
45 | - 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description','event_espresso'), false, ''), |
|
46 | - 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso' ), false, 0 ), |
|
47 | - 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option','event_espresso'), TRUE, NULL ), |
|
48 | - 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed','event_espresso'), false, false) |
|
42 | + 'QSO_ID'=>new EE_Primary_Key_Int_Field('QSO_ID', __('Question Option ID', 'event_espresso')), |
|
43 | + 'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso'), false, 0, 'Question'), |
|
44 | + 'QSO_value'=>new EE_Plain_Text_Field('QSO_value', __("Question Option Value", "event_espresso"), false, ''), |
|
45 | + 'QSO_desc'=>new EE_Post_Content_Field('QSO_desc', __('Question Option Description', 'event_espresso'), false, ''), |
|
46 | + 'QSO_order' => new EE_Integer_Field('QSO_order', __('Question Option Order', 'event_espresso'), false, 0), |
|
47 | + 'QSO_system'=>new EE_Plain_Text_Field('QSO_system', __('Internal string ID for question option', 'event_espresso'), TRUE, NULL), |
|
48 | + 'QSO_deleted'=>new EE_Trashed_Flag_Field('QSO_deleted', __('Flag indicating Option was trashed', 'event_espresso'), false, false) |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 | $this->_model_relations = array( |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | |
55 | 55 | $this->_model_chain_to_wp_user = 'Question'; |
56 | 56 | //this model is generally available for reading |
57 | - $this->_cap_restriction_generators[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
58 | - $this->_cap_restriction_generators[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
59 | - $this->_cap_restriction_generators[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
60 | - $this->_cap_restriction_generators[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
57 | + $this->_cap_restriction_generators[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
58 | + $this->_cap_restriction_generators[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
59 | + $this->_cap_restriction_generators[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
60 | + $this->_cap_restriction_generators[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('Question_Option'); |
|
61 | 61 | $this->_caps_slug = 'questions'; |
62 | - parent::__construct( $timezone ); |
|
62 | + parent::__construct($timezone); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 |