Пример #1
0
 /**
  * create data to post to the internal
  * 
  * @param Np_Method $request the request to create post data from
  * 
  * @return void
  * 
  * @todo refatoring to bridge classes
  */
 protected function createPostData(Np_Method $request)
 {
     $ack = $request->getAck();
     $rejectReasonCode = $request->getRejectReasonCode();
     $idValue = $request->getIDValue();
     if ($this->params['FROM'] != Application_Model_General::getSettings('InternalProvider')) {
         $provider = $this->params['FROM'];
     } else {
         $provider = $this->params['TO'];
     }
     if (!$rejectReasonCode || $rejectReasonCode === "" || $rejectReasonCode == " ") {
         $rejectReasonCode = "OK";
     }
     if (empty($idValue)) {
         $idValue = "no details";
     }
     $ret = array('number' => $this->params['PHONE_NUMBER'], 'provider' => $provider, 'msg_type' => $this->params['MSG_TYPE'], 'msgType' => $this->params['MSG_TYPE'], 'reqId' => $this->params['REQUEST_ID'], 'more' => array('identification_value' => $idValue, 'resultCode' => $rejectReasonCode, 'ack' => $ack));
     if (isset($this->params['PHONE_NUMBER'])) {
         $ret['number'] = $ret['phone_number'] = $this->params['PHONE_NUMBER'];
     }
     if (isset($this->params['NUMBER_TYPE'])) {
         $ret['more']['number_type'] = $this->params['NUMBER_TYPE'];
         if ($ret['more']['number_type'] == "R") {
             unset($ret['number'], $ret['phone_number']);
             $ret['more']['to_number'] = $this->params['TO_NUMBER'];
             $ret['more']['from_number'] = $this->params['FROM_NUMBER'];
         }
     }
     if (Application_Model_General::isMsgResponse($this->params['MSG_TYPE'])) {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
     }
     $msg_type = strtoupper($this->params['MSG_TYPE']);
     if ($msg_type == "KD_UPDATE_RESPONSE") {
         $ret['more']['KD_update_type'] = $this->params['KD_UPDATE_TYPE'];
     }
     if ($msg_type == "EXECUTE_RESPONSE" && isset($this->params['DISCONNECT_TIME'])) {
         $ret['more']['disconnect_time'] = $this->params['DISCONNECT_TIME'];
     }
     if ($msg_type == "REQUEST" || $msg_type == "UPDATE") {
         if (!is_numeric($this->params['PORT_TIME'])) {
             // convert to unix timestamp in case is format as full datetime
             $transfer_time = strtotime($this->params['PORT_TIME']);
         } else {
             $transfer_time = $this->params['PORT_TIME'];
         }
         // all the cases for backward compatibility
         $ret['port_time'] = $ret['more']['port_time'] = $ret['transfer_time'] = $ret['more']['transfer_time'] = $transfer_time;
     }
     if (isset($ret['more']['approval_ind']) && $ret['more']['approval_ind'] == 'Y' && ($msg_type == "REQUEST_RESPONSE" || $msg_type == "UPDATE_RESPONSE") && Application_Model_General::getSettings('InternalProvider') == $this->params['TO']) {
         $transfer_time = Application_Model_General::getFieldFromRequests('transfer_time', $this->params['REQUEST_ID'], 'request_id');
         $ret['more']['transfer_time'] = Application_Model_General::getDateTimeInTimeStamp($transfer_time);
     }
     if ($msg_type == "PUBLISH") {
         $ret['more']['donor'] = $this->params['DONOR'];
         $ret['more']['publish_type'] = $this->params['PUBLISH_TYPE'];
         if (isset($this->params['DISCONNECT_TIME'])) {
             $ret['more']['disconnect_time'] = $this->params['DISCONNECT_TIME'];
         }
         if (isset($this->params['CONNECT_TIME'])) {
             $ret['more']['connect_time'] = $this->params['CONNECT_TIME'];
         }
     }
     if ($msg_type == "CANCEL_PUBLISH") {
         $ret['more']['donor'] = $this->params['DONOR'];
     }
     if ($msg_type == "PUBLISH_RESPONSE") {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         if (isset($this->params['ROUTE_TIME'])) {
             $ret['more']['route_time'] = Application_Model_General::getDateTimeInSqlFormat($this->params['ROUTE_TIME']);
         }
     }
     if ($msg_type == "CANCEL_PUBLISH_RESPONSE") {
         $ret['more']['msg_type'] = "Cancel_Publish_response";
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         $ret['more']['route_time'] = Application_Model_General::getDateTimeInSqlFormat($this->params['ROUTE_TIME']);
     }
     if ($msg_type == "INQUIRE_NUMBER_RESPONSE") {
         $ret['more']['approval_ind'] = $this->params['APPROVAL_IND'];
         $ret['more']['current_operator'] = isset($this->params['CURRENT_OPERATOR']) ? $this->params['CURRENT_OPERATOR'] : '  ';
     }
     if ($msg_type == "DB_SYNCH_REQUEST") {
         $ret['more']['from_date'] = $this->params['FROM_DATE'];
         $ret['more']['to_date'] = $this->params['TO_DATE'];
     }
     if ($msg_type == "DB_SYNCH_RESPONSE") {
         $ret['more']['file_name'] = $this->params['FILE_NAME'];
     }
     // let's keep on backward backward compatibility (b/c) - all more fields should be also in the root
     foreach ($ret['more'] as $k => $v) {
         if (!isset($ret[$k])) {
             $ret[$k] = $v;
         }
     }
     // b/c
     if (!isset($ret['msgDesc'])) {
         $ret['desc'] = '';
     }
     // b/c
     if (!isset($ret['more']['msgDesc'])) {
         $ret['more']['msgDesc'] = '';
     }
     return $ret;
 }