Advertisement
verygoodplugins

Untitled

Jun 10th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1.     public function format_post_data( $post_data ) {
  2.  
  3.         if ( isset( $post_data['contact_id'] ) ) {
  4.             return $post_data;
  5.         }
  6.  
  7.         $defaults = array(
  8.             'notify'    => false,
  9.             'role'      => false
  10.         );
  11.  
  12.         $post_data = array_merge( $defaults, $post_data );
  13.  
  14.         $xml = simplexml_load_string( file_get_contents( 'php://input' ) );
  15.  
  16.         $data = $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://soap.sforce.com/2005/09/outbound')->notifications;
  17.  
  18.         $notifications_count = count( $data->Notification );
  19.  
  20.         if ( $notifications_count > 1 ) {
  21.  
  22.             wp_fusion()->batch->includes();
  23.             wp_fusion()->batch->init();
  24.  
  25.         }
  26.  
  27.         $key = 0;
  28.  
  29.         while ( $key !== $notifications_count ) {
  30.  
  31.             $contact_id = (string) $data->Notification[$key]->sObject->children('urn:sobject.enterprise.soap.sforce.com')->Id;
  32.  
  33.             $post_data['contact_id'] = $contact_id;
  34.  
  35.             if ( $key == 0 ) {
  36.  
  37.                 continue;
  38.  
  39.             } else {
  40.  
  41.                 wp_fusion()->batch->process->push_to_queue( array( 'action' => 'wpf_batch_import_users', 'args' => array( $post_data['contact_id'], $post_data ) ) );
  42.  
  43.             }
  44.  
  45.             $key++;
  46.  
  47.         }
  48.  
  49.         if ( $notifications_count > 1 ) {
  50.  
  51.             wp_fusion()->batch->process->save()->dispatch();
  52.  
  53.         }
  54.  
  55.         return $post_data;
  56.  
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement