update to use fulcrm_crypto

master
Marek Isalski 9 years ago
parent 43608a5aed
commit 9940cc8940

@ -95,19 +95,11 @@ function fulcrm_shoppingcart_get_session_cart( $create = true ) {
}
}
function _fulcrm_shoppingcart_buy_hmac( $product_id ) {
return drupal_hmac_base64( 'fulcrm:' . strval( $product_id ) . ':product_id', session_id() . drupal_get_hash_salt() );
}
function fulcrm_shoppingcart_buy_url( $product_id ) {
$hmac = _fulcrm_shoppingcart_buy_hmac( $product_id );
$hmac = fulcrm_crypto_object_id_hmac( 'product', $product_id );
return url( 'fulcrm/buy/' . $product_id . '/' . $hmac );
}
function _fulcrm_shoppingcart_person_id_hmac( $person_id ) {
return drupal_hmac_base64( 'fulcrm:' . strval( $person_id ) . ':person_id', session_id() . drupal_get_hash_salt() );
}
function fulcrm_shoppingcart_buy_eventbookingtype_form_submit( $form, &$form_state ) {
}
@ -126,18 +118,18 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
);
if ( array_key_exists( 'id', $person ) )
$persons = array( _fulcrm_shoppingcart_person_id_hmac( $person[ 'id' ] ) => 'myself' );
$persons = array( fulcrm_crypto_object_id_hmac( 'person', $person[ 'id' ] ) => 'myself' );
else
$persons = array( 'myself' => 'myself' );
if ( array_key_exists( 'related_from_person2persons', $person ) ) {
foreach ( $person[ 'related_from_person2persons' ] as $p2p ) {
$persons[ _fulcrm_shoppingcart_person_id_hmac( $p2p[ 'related_from' ][ 'id' ] ) ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ fulcrm_crypto_object_id_hmac( 'person', $p2p[ 'related_from' ][ 'id' ] ) ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
}
}
if ( array_key_exists( 'related_to_person2persons', $person ) ) {
foreach ( $person[ 'related_to_person2persons' ] as $p2p ) {
$persons[ _fulcrm_shoppingcart_person_id_hmac( $p2p[ 'related_to' ][ 'id' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ fulcrm_crypto_object_id_hmac( 'person', $p2p[ 'related_to' ][ 'id' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
}
}
@ -169,9 +161,7 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
function fulcrm_shoppingcart_buy( $product_id, $hmac ) {
global $user;
$real_hmac = _fulcrm_shoppingcart_buy_hmac( $product_id );
if ( hash_equals( $real_hmac, $hmac ) ) {
if ( fulcrm_crypto_check_object_id_hmac( 'product', $product_id, $hmac ) ) {
$product_data = fulcrm_apiv2_GET( 'product/' . $product_id . '/',
$query = array( 'expand' => implode( ',', array( 'content_object',
'selector_object',

Loading…
Cancel
Save