Skip to content

Commit

Permalink
internalize the generate_security_code method
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Mar 7, 2018
1 parent 0a0d1a1 commit 99fe19c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ Our Premium Plugins:

== Changelog ==

= [0.2.3] 2017-03-07 =
* Fix support for new and old versions of Event Tickets and Event Tickets Plus by internalizing the `Tribe__Tickets__RSVP::generate_security_code` method

= [0.2.2] 2017-02-19 =
* Add support for the `--reset-total-sales` flag to the `reset-paypal-orders` command

Expand Down
16 changes: 15 additions & 1 deletion src/Tickets/Generator/RSVP/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function generate_attendees( array $args = null, array $assoc_args = null
Tribe__Tickets__RSVP::ATTENDEE_PRODUCT_KEY => $ticket_id,
Tribe__Tickets__RSVP::ATTENDEE_EVENT_KEY => $post_id,
Tribe__Tickets__RSVP::ATTENDEE_RSVP_KEY => $rsvp_status,
$tickets->security_code => $tickets->generate_security_code( $attendee_id ),
$tickets->security_code => $this->generate_security_code( $attendee_id ),
$tickets->order_key => $order_id,
Tribe__Tickets__RSVP::ATTENDEE_OPTOUT_KEY => '',
$tickets->full_name => $attendee_name,
Expand Down Expand Up @@ -201,4 +201,18 @@ public function reset_attendees( array $args = null, array $assoc_args = null )
update_post_meta( $ticket, 'total_sales', 0 );
}
}

/**
* Generates a security code for the atteendee.
*
* A copy of the `Tribe__Tickets__Tickets::generate_security_code` method to
* "internalize" the dependency and avoid having to make said method public.
*
* @param int $attendee_id
*
* @return bool|string
*/
protected function generate_security_code($attendee_id) {
return substr(md5(rand() . '_' . $attendee_id), 0, 10);
}
}

0 comments on commit 99fe19c

Please sign in to comment.