add fulcrm_apiv2_client_id()

master
Marek Isalski 9 years ago
parent 4dfce3b53a
commit a551261090

@ -30,12 +30,16 @@ function fulcrm_apiv2_menu() {
return $items; return $items;
} }
function fulcrm_apiv2_client_id() {
return variable_get( 'fulcrm_apiv2_client_id', $GLOBALS[ 'base_url' ] );
}
function fulcrm_apiv2_prevent_loop( $headers ) { function fulcrm_apiv2_prevent_loop( $headers ) {
$incoming_client_ids = &drupal_static(__FUNCTION__); $incoming_client_ids = &drupal_static(__FUNCTION__);
if ( array_key_exists( 'X-fulcrm-Client-ID', $headers ) ) { if ( array_key_exists( 'X-fulcrm-Client-ID', $headers ) ) {
$incoming_client_ids = array_map( "trim", explode( ',', $headers[ 'X-fulcrm-Client-ID' ] ) ); $incoming_client_ids = array_map( "trim", explode( ',', $headers[ 'X-fulcrm-Client-ID' ] ) );
$client_id = variable_get( 'fulcrm_apiv2_client_id', $GLOBALS[ 'base_url' ] ); $client_id = fulcrm_apiv2_client_id();
if ( in_array( $client_id, $incoming_client_ids ) ) if ( in_array( $client_id, $incoming_client_ids ) )
return false; return false;
} else { } else {
@ -119,7 +123,7 @@ function fulcrm_apiv2_http( $method, $object = null, $data = null, $query = null
$incoming_client_ids = &drupal_static( 'fulcrm_apiv2_prevent_loop' ); $incoming_client_ids = &drupal_static( 'fulcrm_apiv2_prevent_loop' );
if ( !is_array( $incoming_client_ids ) ) if ( !is_array( $incoming_client_ids ) )
$incoming_client_ids = array(); $incoming_client_ids = array();
$incoming_client_ids[] = variable_get( 'fulcrm_apiv2_client_id', $GLOBALS[ 'base_url' ] ); $incoming_client_ids[] = fulcrm_apiv2_client_id();
$request_headers[] = 'X-fulcrm-Client-ID: ' . implode( ', ', $incoming_client_ids ); $request_headers[] = 'X-fulcrm-Client-ID: ' . implode( ', ', $incoming_client_ids );

Loading…
Cancel
Save