3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * CPMObjectEventHandler: BLCampaignsCreate * Package: RN * Objects: BLDialogue\BLCampaigns * Actions: Create,Update * Version: 1.2 */ // This object procedure binds to v1_1 of the Connect PHP API use RightNow\Connect\v1_2 as RNCPHP; // This object procedure binds to the v1 interface of the process // designer use \RightNow\CPM\v1 as RNCPM; /* Campaign create incident, when incident creating, will trigger this handler and send sms. */ /** * An Object Event Handler must provide two classes: * - One with the same name as the CPMObjectEventHandler tag * above that implements the ObjectEventHandler interface. * - And one of the same name with a "_TestHarness" suffix * that implements the ObjectEventHandler_TestHarness interface. * * Each method must have an implementation. */ class BLCampaignsCreate implements RNCPM\ObjectEventHandler { public static $apiUrl = 'https://dialogue.blueleap.com'; public static function apply($run_mode, $action, $obj, $n_cycles) { $actionToPerform = ''; date_default_timezone_set("UTC"); try { if (RNCPM\ActionCreate == $action) { if ($obj->StatusOrExceptionReason == 'SchedulePending') { self::scheduleCampaign($obj, 'schedule'); } else if ($obj->StatusOrExceptionReason == 'Executing') { self::executeCampaign($obj); } } else if (RNCPM\ActionUpdate == $action) { if ($obj->StatusOrExceptionReason == 'UpdatePending') { self::scheduleCampaign($obj, 'update'); } else if ($obj->StatusOrExceptionReason == 'CancelPending') { self::scheduleCampaign($obj, 'cancel'); } else if ($obj->StatusOrExceptionReason == 'Executing') { self::executeCampaign($obj); } } } catch (\Exception $ex) { $obj->StatusOrExceptionCode = 'ble1016'; $obj->StatusOrExceptionReason = 'Failed'; $obj->StatusOrExceptionDescription = 'General script failure - ' . $ex->getMessage(); $obj->save(); echo $ex->getMessage(); } return; } // apply() public static function scheduleCampaign($obj, $action) { $query = "select BLDialogue.BLAccount from BLDialogue.BLAccount"; $result = RNCPHP\ROQL::queryObject($query)->next(); $BLAccount = $result->next(); $tokenResponse = self::getToken($obj, $BLAccount->BLAccountSID, $BLAccount->BLAccountPWD); $tokenArr = json_decode($tokenResponse, true); $BLAccount->BLToken = $tokenArr['token']; $campaignResponse = self::scheduleCampaignServer($obj, $BLAccount, $action); if (strlen($campaignResponse)) { if (($campaignResult = json_decode($campaignResponse))) { $obj->StatusOrExceptionDescription = $campaignResult->StatusMessage; $obj->StatusOrExceptionReason = $campaignResult->RequestStatus; $obj->StatusOrExceptionCode = $campaignResult->RequestStatusCode; } else { // garbage response no json $obj->StatusOrExceptionCode = 'ble1014'; $obj->StatusOrExceptionReason = 'Failed'; $obj->StatusOrExceptionDescription = 'Garbage response from API not a json object.'; } } else { // no response from API $obj->StatusOrExceptionCode = 'ble1013'; $obj->StatusOrExceptionReason = 'Failed'; $obj->StatusOrExceptionDescription = 'No response from API.'; // sms send failed, set status failed and add proper reason } $obj->save(); } public static function executeCampaign($obj) { $obj->StartTime = time(); //$query = "select MarketingSettings.ContactLists.* from Contact limit 1"; $query = "SELECT Contact FROM Contact where MarketingSettings.ContactLists.NamedIDList=" . $obj->ContactListID; //$query = "SELECT Contact FROM Contact where MarketingSettings.ContactLists.NamedIDList=2408"; $result = RNCPHP\ROQL::queryObject($query)->next(); $obj->OptOutCount = 0; //$obj->SMSCreateCount = 0; //$obj->SMSFailedCount = 0; $obj->AudienceCount = 0; $campaign = RNCPHP\BLDialogue\BLCampaigns::fetch($obj->ID); while ($contact = $result->next()) { $campaign = RNCPHP\BLDialogue\BLCampaigns::fetch($obj->ID); if ($campaign->StatusOrExceptionReason == 'Executing') { if ($contact->CustomFields->BLDialogue->sms_opt_out) { $obj->OptOutCount++; } $optedOut = false; if ($contact->CustomFields->BLDialogue->sms_opt_out && $obj->OptOutOverride) $optedOut = false; else if ($contact->CustomFields->BLDialogue->sms_opt_out) $optedOut = true; if (self::saveBlOutboundMessage($contact, $obj, $optedOut)) { //$obj->SMSCreateCount++; } else { //$obj->SMSFailedCount++; } $obj->AudienceCount++; } else { break; } } if ($campaign->StatusOrExceptionReason == 'Executing') { $obj->StatusOrExceptionCode = 'bls1029'; $obj->StatusOrExceptionReason = 'Finished'; $obj->StatusOrExceptionDescription = 'Campaign has finished processing'; } $obj->FinishTime = time(); $obj->save(); } public static function saveBlOutboundMessage($contact, $BlCampaigns, $optedOut) { try { $messageBody = self::getMessageBody($BlCampaigns->MessageBody, $contact); $BlOutboundMessage = new RNCPHP\BLDialogue\BLOutboundMessage(); $BlOutboundMessage->MessageBody = $messageBody; $BlOutboundMessage->AlphaNumeric = $BlCampaigns->AlphaNumeric; $BlOutboundMessage->ContactID = $contact; //$BlOutboundMessage->MessageSID = $messageCount; $BlOutboundMessage->AgentID = $BlCampaigns->AgentID; $BlOutboundMessage->RunTime = $BlCampaigns->RunTime; $BlOutboundMessage->ContactGMToffset = $BlCampaigns->ContactGMToffset; $BlOutboundMessage->MessageType = $BlCampaigns->MessageType; $roql_result_set = RNCPHP\ROQL::query("SELECT Phones.Number from Contact where Phones.PhoneType.ID = 1 and ID=" . $contact->ID)->next()->next(); if (($number = self::formatNumber($roql_result_set['Number'])) === false) { $number = $roql_result_set['Number']; $BlOutboundMessage->StatusOrExceptionCode = 'ble1020'; $BlOutboundMessage->StatusOrExceptionReason = 'Failed'; $BlOutboundMessage->StatusOrExceptionDescription = 'You have attempted to send an SMS with a number that is not a valid mobile number'; // if(($number = self::formatNumber($contact->Phones[0]->Number))===false) // { // $number = $contact->Phones[1]->Number?$contact->Phones[1]->Number:$contact->Phones[0]->Number; // $BlOutboundMessage->StatusOrExceptionCode = 'ble1020'; // $BlOutboundMessage->StatusOrExceptionReason ='Failed'; // } } if ($number == "dnp") { $number = $roql_result_set['Number']; } $BlOutboundMessage->ContactToNumber = $number; //$BlOutboundMessage->ContactFirstName = $contact->Name->First; //$BlOutboundMessage->ContactLastName = $contact->Name->Last; //$BlOutboundMessage->ContactCountry = $contact->Address->Country->Name; //$BlOutboundMessage->ContactState = $contact->Address->StateOrProvince->LookupName; $BlOutboundMessage->CampaignID = $BlCampaigns->ID; $BlOutboundMessage->OptOutOverride = $BlCampaigns->OptOutOverride; //$BlOutboundMessage->MessageDirection = 'Outbound'; //print_r($BlOutboundMessage);exit; if ($optedOut) { $BlOutboundMessage->StatusOrExceptionCode = 'BLE1019'; $BlOutboundMessage->StatusOrExceptionReason = 'Failed'; $BlOutboundMessage->StatusOrExceptionDescription = 'Customer has opted out. SMS channel not available.'; } //echo 'code - '.$BlOutboundMessage->StatusOrExceptionCode.' Number - '.$BlOutboundMessage->ContactToNumber; $BlOutboundMessage->save(); return true; } catch (\Exception $ex) { echo $ex->getMessage(); return false; } } function scheduleCampaignServer($BLCampaign, $BLAccount, $action) { try { $url = self::$apiUrl . '/api/v1/campaigns/'; $headers = array( "Cache-Control: no-cache", "Pragma: no-cache", "Authorization: " . $BLAccount->BLToken ); $context = array( "BLAccountSID" => $BLAccount->BLAccountSID, "Action" => $action, "CustomerDomain" => $BLAccount->CustomerDomain1, "RunTime" => $BLCampaign->RunTime ? gmdate("m/d/Y h:i:s a", $BLCampaign->RunTime) : null, "CampaignID" => $BLCampaign->ID, ); $postargs = http_build_query($context); // Get the curl session object load_curl(); $session = curl_init(); curl_setopt($session, CURLOPT_HTTPHEADER, $headers); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($session, CURLOPT_POST, true); curl_setopt($session, CURLOPT_POSTFIELDS, $postargs); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 1); // Do the POST and then close the session $response = curl_exec($session); $httpcode = curl_getinfo($session); curl_close($session); return $response; } catch (\Exception $ex) { echo $ex->getMessage(); self::apiRequestTimeout($BLCampaign); //throw new RNCPM\CPMException($ex->getMessage(), 500); } } function getToken($BLCampaign, $username, $password) { try { $headers = array( "Cache-Control: no-cache", "Pragma: no-cache", 'Accept: application/json', 'Content-Type: apploication/json', "Authorization: Basic " . base64_encode($username . ":" . $password) ); load_curl(); $session = curl_init(); curl_setopt($session, CURLOPT_HTTPHEADER, $headers); curl_setopt($session, CURLOPT_URL, self::$apiUrl . '/api/v1/token'); curl_setopt($session, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($session, CURLOPT_POST, false); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($session, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 1); $response = curl_exec($session); curl_close($session); return $response; } catch (\Exception $ex) { echo $ex->getMessage(); self::apiRequestTimeout($BLCampaign); //throw new RNCPM\CPMException($ex->getMessage(), 500); } } function apiRequestTimeout($BLCampaign) { $BLCampaign->StatusOrExceptionCode = 'ble1015'; $BLCampaign->StatusOrExceptionReason = 'Failed'; $BLCampaign->StatusOrExceptionDescription = 'API request timeout.'; $BLCampaign->save(); } function getStatusReasonObj($type, $name) { $query = "select " . $type . " from " . $type . " where Name ='" . $name . "'"; $result = RNCPHP\ROQL::queryObject($query)->next(); return $result->next(); } function getMessageBody($messageBody, $contact) { // if($BlCampaigns->MergeFirstName) // { // $messageBody = str_replace('[FIRSTNAME]',$contact->Name->First,$messageBody); // } // if($BlCampaigns->MergeStudentID) // { // $messageBody = str_replace('[STUDENTID]',$data->CustomFields->c->student_id,$messageBody); // } $pattern = "!(?<=[[])[^]]+(?=[]])!"; preg_match_all($pattern, $messageBody, $match); $replace = array(); $i = 0; foreach ($match[0] as $field) { try { $query = 'select Contact.' . $field . ' from Contact where ID=' . $contact->ID; $result = RNCPHP\ROQL::query($query)->next()->next(); $replace[$i] = end($result); } catch (\Exception $ex) { $replace[$i] = ''; } $match[0][$i] = '[' . $field . ']'; $i++; } $messageBody = str_replace($match[0], $replace, $messageBody); return $messageBody; } function formatNumber($number) { $phoneNumber = preg_replace('/[^0-9+]/', '', $number); $query = "select BLDialogue.BLAccount from BLDialogue.BLAccount"; $result = RNCPHP\ROQL::queryObject($query)->next(); $BLAccount = $result->next(); if (substr($phoneNumber, 0, 1) == '+') { return $phoneNumber; } else if (substr($phoneNumber, 0, strlen($BLAccount->LocalCountryCode)) == $BLAccount->LocalCountryCode) { return '+' . $phoneNumber; } if ($BLAccount->LocalCountryCode == "61") { if (substr($phoneNumber, 0, 4) == "0011") { return str_replace("0011", '+', $phoneNumber); } // else if((strlen($phoneNumber)==11 || strlen($phoneNumber)==12) && substr($phoneNumber,0,1)!='+') // { // return '+'.$phoneNumber; // } else if (strlen($phoneNumber) == 8) { return false; } // else if((strlen($phoneNumber)==10 && (!in_array(substr($phoneNumber, 0, 2),["04","05"]))) || (strlen($phoneNumber)==9 && (!in_array(substr($phoneNumber, 0, 1),["4","5"]))) ) // { // return false; // } else if ((strlen($phoneNumber) == 10 && in_array(substr($phoneNumber, 0, 2), ["04", "05"])) || (strlen($phoneNumber) == 9 && in_array(substr($phoneNumber, 0, 1), ["4", "5"]) )) { $phoneNumber = strlen($phoneNumber) == 10 ? substr($phoneNumber, 1) : $phoneNumber; return '+61' . $phoneNumber; } else if ((strlen($phoneNumber) == 10 && in_array(substr($phoneNumber, 0, 2), ["02", "03", "07", "08"])) || (strlen($phoneNumber) == 9 && in_array(substr($phoneNumber, 0, 2), ["2", "3", "7", "8"]))) { return false; } else if (strlen($phoneNumber) == 9) { return '+61' . $phoneNumber; } } else { if (substr($phoneNumber, 0, 1) == '0') $phoneNumber = substr($phoneNumber, 1); return '+' . $BLAccount->LocalCountryCode . $phoneNumber; } return false; } /* * *******End************ */ } // class incident_name /* The Test Harness */ class BLCampaignsCreate_TestHarness implements RNCPM\ObjectEventHandler_TestHarness { static $co_invented = NULL; public static function setup() { try { $query = "SELECT MarketingSettings.ContactLists.NamedIDList.ID FROM Contact limit 1"; $result = RNCPHP\ROQL::query($query)->next()->next(); if (isset($result['ID'])) { $contact = RNCPHP\Contact::first(); //echo "creating contact"; $BlCampaign = new RNCPHP\BLDialogue\BLCampaigns(); $BlCampaign->CampaignName = 'Event Handler Test Case'; //$BlCampaign->RunTime = strtotime('2017-12-12 12:00:00' ); $BlCampaign->ContactListID = $result['ID']; $BlCampaign->OptOutOverride = 0; $BlCampaign->AlphaNumeric = 0; //$BlCampaign->MergeStudentID = 0; //$BlCampaign->MergeFirstName = 0; $BlCampaign->AgentID = $contact; $BlCampaign->MessageBody = 'Event Handler Test Case Sample message'; $BlCampaign->MessageType = 'Message Campaign'; $BlCampaign->StatusOrExceptionCode = 'bls1022'; $BlCampaign->StatusOrExceptionReason = 'Executing'; $BlCampaign->StatusOrExceptionDescription = 'Camapign is being processed'; $BlCampaign->save(); static::$co_invented = $BlCampaign; } } catch (RNCPHP\ConnectAPIErrorFatal $err) { echo "Error in test harness save contact : " . $err->getCode(); } return; } public static function fetchObject($action, $object_type) { // Return the object that we // want to test with. // You could also return an array of objects // to test more than one variation of an object. //$obj = RNCPHP\BLDialogue\BLCampaigns::fetch(289); //return $obj; return static::$co_invented?static::$co_invented: array(); //return array(); } public static function validate($action, $object) { return(1); } public static function cleanup() { // Destroy every object invented // by this test. // Not necessary since in test // mode and nothing is committed, // but good practice if only to // document the side effects of // this test. if (static::$co_invented) { static::$co_invented->destroy(); static::$co_invented = NULL; } return; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o9jZf
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   DECLARE_CLASS                                            'blcampaignscreate'
  450     1        DECLARE_CLASS                                            'blcampaignscreate_testharness'
  528     2      > RETURN                                                   1

Class BLCampaignsCreate:
Function apply:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 26
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 25
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 51
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 37
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 45
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 51
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 67
Branch analysis from position: 67
Branch analysis from position: 51
Branch analysis from position: 51
Found catch point at position: 52
Branch analysis from position: 52
2 jumps found. (Code = 107) Position 1 = 53, Position 2 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o9jZf
function name:  apply
number of ops:  69
compiled vars:  !0 = $run_mode, !1 = $action, !2 = $obj, !3 = $n_cycles, !4 = $actionToPerform, !5 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   37     4        ASSIGN                                                   !4, ''
   38     5        INIT_FCALL                                               'date_default_timezone_set'
          6        SEND_VAL                                                 'UTC'
          7        DO_ICALL                                                 
   41     8        FETCH_CONSTANT                                   ~8      'RightNow%5CCPM%5Cv1%5CActionCreate'
          9        IS_EQUAL                                                 !1, ~8
         10      > JMPZ                                                     ~9, ->26
   43    11    >   FETCH_OBJ_R                                      ~10     !2, 'StatusOrExceptionReason'
         12        IS_EQUAL                                                 ~10, 'SchedulePending'
         13      > JMPZ                                                     ~11, ->19
   45    14    >   INIT_STATIC_METHOD_CALL                                  'scheduleCampaign'
         15        SEND_VAR_EX                                              !2
         16        SEND_VAL_EX                                              'schedule'
         17        DO_FCALL                                      0          
         18      > JMP                                                      ->25
   47    19    >   FETCH_OBJ_R                                      ~13     !2, 'StatusOrExceptionReason'
         20        IS_EQUAL                                                 ~13, 'Executing'
         21      > JMPZ                                                     ~14, ->25
   49    22    >   INIT_STATIC_METHOD_CALL                                  'executeCampaign'
         23        SEND_VAR_EX                                              !2
         24        DO_FCALL                                      0          
         25    > > JMP                                                      ->51
   52    26    >   FETCH_CONSTANT                                   ~16     'RightNow%5CCPM%5Cv1%5CActionUpdate'
         27        IS_EQUAL                                                 !1, ~16
         28      > JMPZ                                                     ~17, ->51
   54    29    >   FETCH_OBJ_R                                      ~18     !2, 'StatusOrExceptionReason'
         30        IS_EQUAL                                                 ~18, 'UpdatePending'
         31      > JMPZ                                                     ~19, ->37
   56    32    >   INIT_STATIC_METHOD_CALL                                  'scheduleCampaign'
         33        SEND_VAR_EX                                              !2
         34        SEND_VAL_EX                                              'update'
         35        DO_FCALL                                      0          
         36      > JMP                                                      ->51
   58    37    >   FETCH_OBJ_R                                      ~21     !2, 'StatusOrExceptionReason'
         38        IS_EQUAL                                                 ~21, 'CancelPending'
         39      > JMPZ                                                     ~22, ->45
   60    40    >   INIT_STATIC_METHOD_CALL                                  'scheduleCampaign'
         41        SEND_VAR_EX                                              !2
         42        SEND_VAL_EX                                              'cancel'
         43        DO_FCALL                                      0          
         44      > JMP                                                      ->51
   62    45    >   FETCH_OBJ_R                                      ~24     !2, 'StatusOrExceptionReason'
         46        IS_EQUAL                                                 ~24, 'Executing'
         47      > JMPZ                                                     ~25, ->51
   64    48    >   INIT_STATIC_METHOD_CALL                                  'executeCampaign'
         49        SEND_VAR_EX                                              !2
         50        DO_FCALL                                      0          
         51    > > JMP                                                      ->67
   68    52  E > > CATCH                                       last         'Exception'
   70    53    >   ASSIGN_OBJ                                               !2, 'StatusOrExceptionCode'
         54        OP_DATA                                                  'ble1016'
   71    55        ASSIGN_OBJ                                               !2, 'StatusOrExceptionReason'
         56        OP_DATA                                                  'Failed'
   72    57        INIT_METHOD_CALL                                         !5, 'getMessage'
         58        DO_FCALL                                      0  $30     
         59        CONCAT                                           ~31     'General+script+failure+-+', $30
         60        ASSIGN_OBJ                                               !2, 'StatusOrExceptionDescription'
         61        OP_DATA                                                  ~31
   73    62        INIT_METHOD_CALL                                         !2, 'save'
         63        DO_FCALL                                      0          
   74    64        INIT_METHOD_CALL                                         !5, 'getMessage'
         65        DO_FCALL                                      0  $33     
         66        ECHO                                                     $33
   76    67    > > RETURN                                                   null
   77    68*     > RETURN                                                   null

End of function apply

Function schedulecampaign:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 60
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 53
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 42) Position 1 = 66
Branch analysis from position: 66
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o9jZf
function name:  scheduleCampaign
number of ops:  69
compiled vars:  !0 = $obj, !1 = $action, !2 = $query, !3 = $result, !4 = $BLAccount, !5 = $tokenResponse, !6 = $tokenArr, !7 = $campaignResponse, !8 = $campaignResult
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   81     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   84     2        ASSIGN                                                   !2, 'select+BLDialogue.BLAccount+from+BLDialogue.BLAccount'
   85     3        INIT_STATIC_METHOD_CALL                                  'RightNow%5CConnect%5Cv1_2%5CROQL', 'queryObject'
          4        SEND_VAR_EX                                              !2
          5        DO_FCALL                                      0  $10     
          6        INIT_METHOD_CALL                                         $10, 'next'
          7        DO_FCALL                                      0  $11     
          8        ASSIGN                                                   !3, $11
   86     9        INIT_METHOD_CALL                                         !3, 'next'
         10        DO_FCALL                                      0  $13     
         11        ASSIGN                                                   !4, $13
   87    12        INIT_STATIC_METHOD_CALL                                  'getToken'
         13        SEND_VAR_EX                                              !0
         14        CHECK_FUNC_ARG                                           
         15        FETCH_OBJ_FUNC_ARG                               $15     !4, 'BLAccountSID'
         16        SEND_FUNC_ARG                                            $15
         17        CHECK_FUNC_ARG                                           
         18        FETCH_OBJ_FUNC_ARG                               $16     !4, 'BLAccountPWD'
         19        SEND_FUNC_ARG                                            $16
         20        DO_FCALL                                      0  $17     
         21        ASSIGN                                                   !5, $17
   88    22        INIT_FCALL                                               'json_decode'
         23        SEND_VAR                                                 !5
         24        SEND_VAL                                                 <true>
         25        DO_ICALL                                         $19     
         26        ASSIGN                                                   !6, $19
   89    27        FETCH_DIM_R                                      ~22     !6, 'token'
         28        ASSIGN_OBJ                                               !4, 'BLToken'
         29        OP_DATA                                                  ~22
   90    30        INIT_STATIC_METHOD_CALL                                  'scheduleCampaignServer'
         31        SEND_VAR_EX                                              !0
         32        SEND_VAR_EX                                              !4
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $23     
         35        ASSIGN                                                   !7, $23
   91    36        STRLEN                                           ~25     !7
         37      > JMPZ                                                     ~25, ->60
   94    38    >   INIT_FCALL                                               'json_decode'
         39        SEND_VAR                                                 !7
         40        DO_ICALL                                         $26     
         41        ASSIGN                                           ~27     !8, $26
         42      > JMPZ                                                     ~27, ->53
   98    43    >   FETCH_OBJ_R                                      ~29     !8, 'StatusMessage'
         44        ASSIGN_OBJ                                               !0, 'StatusOrExceptionDescription'
         45        OP_DATA                                                  ~29
   99    46        FETCH_OBJ_R                                      ~31     !8, 'RequestStatus'
         47        ASSIGN_OBJ                                               !0, 'StatusOrExceptionReason'
         48        OP_DATA                                                  ~31
  100    49        FETCH_OBJ_R                                      ~33     !8, 'RequestStatusCode'
         50        ASSIGN_OBJ                                               !0, 'StatusOrExceptionCode'
         51        OP_DATA                                                  ~33
         52      > JMP                                                      ->59
  105    53    >   ASSIGN_OBJ                                               !0, 'StatusOrExceptionCode'
         54        OP_DATA                                                  'ble1014'
  106    55        ASSIGN_OBJ                                               !0, 'StatusOrExceptionReason'
         56        OP_DATA                                                  'Failed'
  107    57        ASSIGN_OBJ                                               !0, 'StatusOrExceptionDescription'
         58        OP_DATA                                                  'Garbage+response+from+API+not+a+json+object.'
         59    > > JMP                                                      ->66
  113    60    >   ASSIGN_OBJ                                               !0, 'StatusOrExceptionCode'
         61        OP_DATA                                                  'ble1013'
  114    62        ASSIGN_OBJ                                               !0, 'StatusOrExceptionReason'
         63        OP_DATA                                                  'Failed'
  115    64        ASSIGN_OBJ                                               !0, 'StatusOrExceptionDescription'
         65        OP_DATA                                                  'No+response+from+API.'
  118    66    >   INIT_METHOD_CALL                                         !0, 'save'
         67        DO_FCALL                                      0          
  119    68      > RETURN                                                   null

End of function schedulecampaign

Function executecampaign:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 44) Position 1 = 68, Position 2 = 25
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 77
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 63
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 39
Branch analysis from position: 38
2 jumps found. (Code = 46) Position 1 = 44, Position 2 = 46
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 49
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 61
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 61
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 54
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
Branch analysis from position: 61
Branch analysis from position: 54
Branch analysis from position: 46
Branch analysis from position: 39
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
filename:       /in/o9jZf
function name:  executeCampaign
number of ops:  84
compiled vars:  !0 = $obj, !1 = $query, !2 = $result, !3 = $campaign, !4 = $contact, !5 = $optedOut
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  121     0  E >   RECV                                             !0      
  123     1        INIT_FCALL                                               'time'
          2        DO_ICALL                                         $7      
          3        ASSIGN_OBJ                                               !0, 'StartTime'
          4        OP_DATA                                                  $7
  125     5        FETCH_OBJ_R                                      ~8      !0, 'ContactListID'
          6        CONCAT                                           ~9      'SELECT+Contact+FROM+Contact+where+MarketingSettings.ContactLists.NamedIDList%3D', ~8
          7        ASSIGN                                                   !1, ~9
  127     8        INIT_STATIC_METHOD_CALL                                  'RightNow%5CConnect%5Cv1_2%5CROQL', 'queryObject'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $11     
         11        INIT_METHOD_CALL                                         $11, 'next'
         12        DO_FCALL                                      0  $12     
         13        ASSIGN                                                   !2, $12
  129    14        ASSIGN_OBJ                                               !0, 'OptOutCount'
         15        OP_DATA                                                  0
  132    16        ASSIGN_OBJ                                               !0, 'AudienceCount'
         17        OP_DATA                                                  0
  133    18        INIT_STATIC_METHOD_CALL                                  'RightNow%5CConnect%5Cv1_2%5CBLDialogue%5CBLCampaigns', 'fetch'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_FUNC_ARG                               $16     !0, 'ID'
         21        SEND_FUNC_ARG                                            $16
         22        DO_FCALL                                      0  $17     
         23        ASSIGN                                                   !3, $17
  135    24      > JMP                                                      ->64
  137    25    >   INIT_STATIC_METHOD_CALL                                  'RightNow%5CConnect%5Cv1_2%5CBLDialogue%5CBLCampaigns', 'fetch'
         26        CHECK_FUNC_ARG                                           
         27        FETCH_OBJ_FUNC_ARG                               $19     !0, 'ID'
         28        SEND_FUNC_ARG                                            $19
         29        DO_FCALL                                      0  $20     
         30        ASSIGN                                                   !3, $20
  138    31        FETCH_OBJ_R                                      ~22     !3, 'StatusOrExceptionReason'
         32        IS_EQUAL                                                 ~22, 'Executing'
         33      > JMPZ                                                     ~23, ->63
  140    34    >   FETCH_OBJ_R                                      ~24     !4, 'CustomFields'
         35        FETCH_OBJ_R                                      ~25     ~24, 'BLDialogue'
         36        FETCH_OBJ_R                                      ~26     ~25, 'sms_opt_out'
         37      > JMPZ                                                     ~26, ->39
  142    38    >   PRE_INC_OBJ                                              !0, 'OptOutCount'
  144    39    >   ASSIGN                                                   !5, <false>
  145    40        FETCH_OBJ_R                                      ~29     !4, 'CustomFields'
         41        FETCH_OBJ_R                                      ~30     ~29, 'BLDialogue'
         42        FETCH_OBJ_R                                      ~31     ~30, 'sms_opt_out'
         43      > JMPZ_EX                                          ~31     ~31, ->46
         44    >   FETCH_OBJ_R                                      ~32     !0, 'OptOutOverride'
         45        BOOL                                             ~31     ~32
         46    > > JMPZ                                                     ~31, ->49
  146    47    >   ASSIGN                                                   !5, <false>
         48      > JMP                                                      ->54
  147    49    >   FETCH_OBJ_R                                      ~34     !4, 'CustomFields'
         50        FETCH_OBJ_R                                      ~35     ~34, 'BLDialogue'
         51        FETCH_OBJ_R                                      ~36     ~35, 'sms_opt_out'
         52      > JMPZ                                                     ~36, ->54
  148    53    >   ASSIGN                                                   !5, <true>
  150    54    >   INIT_STATIC_METHOD_CALL                                  'saveBlOutboundMessage'
         55        SEND_VAR_EX                                              !4
         56        SEND_VAR_EX                                              !0
         57        SEND_VAR_EX                                              !5
         58        DO_FCALL                                      0  $38     
         59      > JMPZ                                                     $38, ->61
  151    60    > > JMP                                                      ->61
  160    61    >   PRE_INC_OBJ                                              !0, 'AudienceCount'
         62      > JMP                                                      ->64
  164    63    > > JMP                                                      ->68
  135    64    >   INIT_METHOD_CALL                                         !2, 'next'
         65        DO_FCALL                                      0  $40     
         66        ASSIGN                                           ~41     !4, $40
         67      > JMPNZ                                                    ~41, ->25
  167    68    >   FETCH_OBJ_R                                      ~42     !3, 'StatusOrExceptionReason'
         69        IS_EQUAL                                                 ~42, 'Executing'
         70      > JMPZ                                                     ~43, ->77
  169    71    >   ASSIGN_OBJ                                               !0, 'StatusOrExceptionCode'
         72        OP_DATA                                                  'bls1029'
  170    73        ASSIGN_OBJ                                               !0, 'StatusOrExceptionReason'
         74        OP_DATA                                                  'Finished'
  171    75        ASSIGN_OBJ                                               !0, 'StatusOrExceptionDescription'
         76        OP_DATA                                                  'Campaign+has+finished+processing'
  175    77    >   INIT_FCALL                                               'time'
         78        DO_ICALL                                         $48     
         79        ASSIGN_OBJ                                               !0, 'FinishTime'
         80        OP_DATA                                                  $48
  176    81        INIT_METHOD_CALL                                         !0, 'save'
         82        DO_FCALL                                      0          
  177    83      > RETURN                                                   null

End of function executecampaign

Function savebloutboundmessage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 50, Position 2 = 58
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 62
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 77
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 77
Branch analysis from position: 62
Branch analysis from position: 58
Found catch point at position: 81
Branch analysis from position: 81
2 jumps found. (Code = 107) Position 1 = 82, Position 2 = -2
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/o9jZf
function name:  saveBlOutboundMessage
number of ops:  87
compiled vars:  !0 = $contact, !1 = $BlCampaigns, !2 = $optedOut, !3 = $messageBody, !4 = $BlOutboundMessage, !5 = $roql_result_set, !6 = $number, !7 = $ex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  179     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
  184     3        INIT_STATIC_METHOD_CALL                                  'getMessageBody'
          4        CHECK_FUNC_ARG                                           
          5        FETCH_OBJ_FUNC_ARG                               $8      !1, 'MessageBody'
          6        SEND_FUNC_ARG                                            $8
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !3, $9
  185    10        NEW                                              $11     'RightNow%5CConnect%5Cv1_2%5CBLDialogue%5CBLOutboundMessage'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !4, $11
  186    13        ASSIGN_OBJ                                               !4, 'MessageBody'
         14        OP_DATA                                                  !3
  187    15        FETCH_OBJ_R                                      ~16     !1, 'AlphaNumeric'
         16        ASSIGN_OBJ                                               !4, 'AlphaNumeric'
         17        OP_DATA                                                  ~16
  188    18        ASSIGN_OBJ                                               !4, 'ContactID'
         19        OP_DATA                                                  !0
  190    20        FETCH_OBJ_R                                      ~19     !1, 'AgentID'
         21        ASSIGN_OBJ                                               !4, 'AgentID'
         22        OP_DATA                                                  ~19
  191    23        FETCH_OBJ_R                                      ~21     !1, 'RunTime'
         24        ASSIGN_OBJ                                               !4, 'RunTime'
         25        OP_DATA                                                  ~21
  192    26        FETCH_OBJ_R                                      ~23     !1, 'ContactGMToffset'
         27        ASSIGN_OBJ                                               !4, 'ContactGMToffset'
         28        OP_DATA                                                  ~23
  193    29        FETCH_OBJ_R                                      ~25     !1, 'MessageType'
         30        ASSIGN_OBJ                                               !4, 'MessageType'
         31        OP_DATA                                                  ~25
  194    32        INIT_STATIC_METHOD_CALL                                  'RightNow%5CConnect%5Cv1_2%5CROQL', 'query'
         33        FETCH_OBJ_R                                      ~26     !0, 'ID'
         34        CONCAT                                           ~27     'SELECT+Phones.Number+from+Contact+where+Phones.PhoneType.ID+%3D+1+and++ID%3D', ~26
         35        SEND_VAL_EX                                              ~27
         36        DO_FCALL                                      0  $28     
         37        INIT_METHOD_CALL                                         $28, 'next'
         38        DO_FCALL                                      0  $29     
         39        INIT_METHOD_CALL                                         $29, 'next'
         40        DO_FCALL                                      0  $30     
         41        ASSIGN                                                   !5, $30
  196    42        INIT_STATIC_METHOD_CALL                                  'formatNumber'
         43        CHECK_FUNC_ARG                                           
         44        FETCH_DIM_FUNC_ARG                               $32     !5, 'Number'
         45        SEND_FUNC_ARG                                            $32
         46        DO_FCALL                                      0  $33     
         47        ASSIGN                                           ~34     !6, $33
         48        TYPE_CHECK                                    4          ~34
         49      > JMPZ                                                     ~35, ->58
  198    50    >   FETCH_DIM_R                                      ~36     !5, 'Number'
         51        ASSIGN                                                   !6, ~36
  199    52        ASSIGN_OBJ                                               !4, 'StatusOrExceptionCode'
         53        OP_DATA                                                  'ble1020'
  200    54        ASSIGN_OBJ                                               !4, 'StatusOrExceptionReason'
         55        OP_DATA                                                  'Failed'
  201    56        ASSIGN_OBJ                                               !4, 'StatusOrExceptionDescription'
         57        OP_DATA                                                  'You+have+attempted+to+send+an+SMS+with+a+number+that+is+not+a+valid+mobile+number'
  209    58    >   IS_EQUAL                                                 !6, 'dnp'
         59      > JMPZ                                                     ~41, ->62
  211    60    >   FETCH_DIM_R                                      ~42     !5, 'Number'
         61        ASSIGN                                                   !6, ~42
  215    62    >   ASSIGN_OBJ                                               !4, 'ContactToNumber'
         63        OP_DATA                                                  !6
  220    64        FETCH_OBJ_R                                      ~46     !1, 'ID'
         65        ASSIGN_OBJ                                               !4, 'CampaignID'
         66        OP_DATA                                                  

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.21 ms | 1428 KiB | 19 Q