|
|
@ -30,6 +30,20 @@ function fulcrm_apiv2_menu() {
|
|
|
|
return $items;
|
|
|
|
return $items;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_apiv2_prevent_loop( $headers ) {
|
|
|
|
|
|
|
|
$incoming_client_ids = &drupal_static(__FUNCTION__);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( array_key_exists( 'X-fulcrm-Client-ID', $headers ) ) {
|
|
|
|
|
|
|
|
$incoming_client_ids = array_map( "trim", explode( ',', $headers[ 'X-fulcrm-Client-ID' ] ) );
|
|
|
|
|
|
|
|
if ( in_array( $client_id, $incoming_client_ids ) )
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$incoming_client_ids = array();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function fulcrm_apiv2_http( $method, $object = null, $data = null, $query = null ) {
|
|
|
|
function fulcrm_apiv2_http( $method, $object = null, $data = null, $query = null ) {
|
|
|
|
$url = null;
|
|
|
|
$url = null;
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +90,12 @@ function fulcrm_apiv2_http( $method, $object = null, $data = null, $query = null
|
|
|
|
$request_headers[] = 'Content-Length: ' . strlen( $data );
|
|
|
|
$request_headers[] = 'Content-Length: ' . strlen( $data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$request_headers[] = 'X-fulcrm-Client-ID: ' . variable_get( 'fulcrm_apiv2_client_id', $GLOBALS[ 'base_url' ] );
|
|
|
|
$incoming_client_ids = &drupal_static( 'fulcrm_apiv2_prevent_loop' );
|
|
|
|
|
|
|
|
if ( !is_array( $incoming_client_ids ) )
|
|
|
|
|
|
|
|
$incoming_client_ids = array();
|
|
|
|
|
|
|
|
$incoming_client_ids[] = variable_get( 'fulcrm_apiv2_client_id', $GLOBALS[ 'base_url' ] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$request_headers[] = 'X-fulcrm-Client-ID: ' . implode( ', ', $incoming_client_ids );
|
|
|
|
|
|
|
|
|
|
|
|
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
|
|
|
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
|
|
|
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
|
|
|
|
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
|
|
|
|