@@ 488-504 (lines=17) @@ | ||
485 | * @throws InvalidInterfaceException |
|
486 | * @throws ReflectionException |
|
487 | */ |
|
488 | public function reserve_ticket($update_ticket = false, $source = 'unknown') |
|
489 | { |
|
490 | // only reserve ticket if space is not currently reserved |
|
491 | if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) !== true) { |
|
492 | $this->update_extra_meta('reserve_ticket', "{$this->ticket_ID()} from {$source}"); |
|
493 | // IMPORTANT !!! |
|
494 | // although checking $update_ticket first would be more efficient, |
|
495 | // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
496 | if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) |
|
497 | && $update_ticket |
|
498 | ) { |
|
499 | $ticket = $this->ticket(); |
|
500 | $ticket->increaseReserved(1, "REG: {$this->ID()} (ln:" . __LINE__ . ')'); |
|
501 | $ticket->save(); |
|
502 | } |
|
503 | } |
|
504 | } |
|
505 | ||
506 | ||
507 | /** |
|
@@ 519-534 (lines=16) @@ | ||
516 | * @throws InvalidInterfaceException |
|
517 | * @throws ReflectionException |
|
518 | */ |
|
519 | public function release_reserved_ticket($update_ticket = false, $source = 'unknown') |
|
520 | { |
|
521 | // only release ticket if space is currently reserved |
|
522 | if ((bool) $this->get_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, true) === true) { |
|
523 | $this->update_extra_meta('release_reserved_ticket', "{$this->ticket_ID()} from {$source}"); |
|
524 | // IMPORTANT !!! |
|
525 | // although checking $update_ticket first would be more efficient, |
|
526 | // we NEED to ALWAYS call update_extra_meta(), which is why that is done first |
|
527 | if ($this->update_extra_meta(EE_Registration::HAS_RESERVED_TICKET_KEY, false) |
|
528 | && $update_ticket |
|
529 | ) { |
|
530 | $ticket = $this->ticket(); |
|
531 | $ticket->decreaseReserved(1, true, "REG: {$this->ID()} (ln:" . __LINE__ . ')'); |
|
532 | } |
|
533 | } |
|
534 | } |
|
535 | ||
536 | ||
537 | /** |