add actions; remove debug code; HMAC person_ids

master
Marek Isalski 9 years ago
parent 4e2a878b88
commit 92c6e20b98

@ -104,6 +104,14 @@ function fulcrm_shoppingcart_buy_url( $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 ) {
}
function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $person, $eventbookingtype, $product ) {
$form = array();
@ -118,26 +126,26 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
);
if ( array_key_exists( 'id', $person ) )
$persons = array( $person[ 'id' ] => 'myself' );
$persons = array( _fulcrm_shoppingcart_person_id_hmac( $person[ 'id' ] ) => 'myself' );
else
$persons = array( 0 => 'myself' );
$persons = array( 'myself' => 'myself' );
if ( array_key_exists( 'related_from_person2persons', $person ) ) {
foreach ( $person[ 'related_from_person2persons' ] as $p2p ) {
$persons[ $p2p[ 'related_from' ][ 'id' ] ] = $p2p[ 'related_from' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ _fulcrm_shoppingcart_person_id_hmac( $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[ $p2p[ 'related_to' ][ 'id' ] ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
$persons[ _fulcrm_shoppingcart_person_id_hmac( $p2p[ 'related_to' ][ 'id' ] ) ] = $p2p[ 'related_to' ][ 'name' ] . ' (your ' . $p2p[ 'relationship' ][ 'name' ] . ')';
}
}
$form[ 'tickets_for_persons' ] = array( '#type' => 'checkboxes',
'#title' => 'Who is coming to the event?',
'#description' => 'Tick the box next to each person for whom you want to buy a ticket.',
'#options' => $persons,
);
$form[ 'ticket_for_persons' ] = array( '#type' => 'checkboxes',
'#title' => 'Who is coming to the event?',
'#description' => 'Tick the box next to each person for whom you want to buy a ticket.',
'#options' => $persons,
);
$form[ 'tickets_for_others' ] = array( '#type' => 'select',
'#title' => 'How many tickets would you like for other people?',
'#description' => 'Choose how many tickets you are getting for other people. You\'ll be asked their names soon.',
@ -149,12 +157,11 @@ function fulcrm_shoppingcart_buy_eventbookingtype_form( $form, &$form_state, $pe
),
);
$form[ 'person' ] = array( '#type' => 'markup',
'#markup' => '<pre>' . print_r( $person, 1 ) . '</pre>' );
$form[ 'eventbookingtype' ] = array( '#type' => 'markup',
'#markup' => '<pre>' . print_r( $eventbookingtype, 1 ) . '</pre>' );
$form[ 'product' ] = array( '#type' => 'markup',
'#markup' => '<pre>' . print_r( $product, 1 ) . '</pre>' );
$form[ 'actions' ] = array( '#type' => 'actions' );
$form[ 'actions' ][ 'save' ] = array( '#type' => 'submit',
'#value' => t('Add to Basket'),
'#submit' => array( 'fulcrm_shoppingcart_buy_eventbookingtype_form_submit' ),
);
return $form;
}

Loading…
Cancel
Save