コード例 #1
0
ファイル: Cron.php プロジェクト: carriercomm/NPG
 /**
  * locks request process according to request id 
  * and sends execute message to provider
  * 
  * @param array $request 
  * @return void
  */
 public function executeTransferOut($request)
 {
     $params = array('REQUEST_ID' => $request['request_id'], 'PROCESS_TYPE' => "PORT", 'MSG_TYPE' => "Execute_response", 'TO' => Application_Model_General::getSettings('InternalProvider'), 'FROM' => $request['from_provider'], "RETRY_DATE" => Application_Model_General::getDateTimeIso(), "RETRY_NO" => "1", "VERSION_NO" => Application_Model_General::getSettings("VersionNo"));
     $reqModel = new Application_Model_Request($params);
     // make sure the request is ok.
     // can use $reqModel->RequestValidate() but maybe there is no need becuse i'm building it
     //fix bug #5285
     $params['PHONE_NUMBER'] = Application_Model_General::getFieldFromRequests("phone_number", $params['REQUEST_ID']);
     //end of fix bug #5285
     Application_Model_General::writeToLog($params);
     $reqModel->ExecuteFromInternal();
 }
コード例 #2
0
ファイル: KDUpdate.php プロジェクト: carriercomm/NPG
 public function createXml()
 {
     $xml = parent::createXml();
     $msgType = $this->getHeaderField('MSG_TYPE');
     $networkType = Application_Model_General::getSettings("NetworkType");
     $numberType = $this->getBodyField('NUMBER_TYPE');
     $requestId = $this->getHeaderField('REQUEST_ID');
     $requestRecord = Application_Model_General::getFieldFromRequests(array('flags', 'transfer_time'), $requestId, 'request_id');
     $flags = json_decode($requestRecord['flags'], true);
     if (empty($numberType)) {
         $numberType = isset($flags['number_type']) ? $flags['number_type'] : Application_Model_General::getSettings("NumberType");
     }
     $number = $this->getBodyField('NUMBER');
     $portTime = Application_Model_General::getDateTimeIso($requestRecord['transfer_time']);
     $process_type = $this->getHeaderField('PROCESS_TYPE');
     if ($process_type == "PORT") {
         $path =& $xml->{$msgType}->updateRequestType;
         $path->updateType = "REQUEST";
         $path->portingDateTime = $portTime;
     } else {
         if ($process_type == "CANCEL") {
             $path =& $xml->{$msgType}->updateCancelTypeType;
             $path->updateType = "CANCEL";
             $path->portingDateTime = $portTime;
         } else {
             if ($process_type == "UPDATE") {
                 $path =& $xml->{$msgType}->updateUpdateTypeType;
                 $path->updateType = "UPDATE";
                 $path->portingDateTime = $portTime;
             }
         }
     }
     if ($networkType === "M") {
         $networkType = "mobile";
     } else {
         $networkType = "fixed";
     }
     $path->{$networkType};
     $path->{$networkType}->networkType = "M";
     if ($numberType === "I") {
         $path->{$networkType}->mobileNumberIdentified;
         $path->{$networkType}->mobileNumberIdentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberIdentified->identificationValue = isset($flags['identification_value']) ? $flags['identification_value'] : 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue2nd = 'default';
         $path->{$networkType}->mobileNumberIdentified->identificationValue3rd = 'default';
         $path->{$networkType}->mobileNumberIdentified->number = $number;
     } else {
         $path->{$networkType}->mobileNumberUnidentified;
         $path->{$networkType}->mobileNumberUnidentified->numberType = $numberType;
         $path->{$networkType}->mobileNumberUnidentified->number = $number;
     }
     return $xml;
 }
コード例 #3
0
ファイル: Check.php プロジェクト: carriercomm/NPG
 /**
  *
  * extended function from parent Np_Method
  * 
  * @return mixed bool string reject reason code or TRUE (valid)
  */
 public function PostValidate()
 {
     $ret = parent::PostValidate();
     if ($ret !== true) {
         return $ret;
     }
     if ($this->getBodyField("NETWORK_TYPE") != Application_Model_General::getSettings("NetworkType")) {
         return "Chk18";
     }
     $inProcessArray = Application_Model_General::$inProcess;
     $inProcess = Application_Model_General::getFieldFromRequests('last_transaction', $this->getBodyField('NUMBER'));
     if (!empty($inProcess) && in_array($inProcess, $inProcessArray)) {
         return "Chk04";
     }
     $number = $this->getBodyField("NUMBER");
     if (!is_numeric($number) || strlen($number) < 8) {
         $this->setAck('Ack02');
         return false;
     }
     return true;
 }
コード例 #4
0
ファイル: Internal.php プロジェクト: carriercomm/NPG
 /**
  * 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;
 }
コード例 #5
0
ファイル: Request.php プロジェクト: carriercomm/NPG
 /**
  * internal send SOAP
  * check InternalPostValidate()
  * if true saves to db
  * sends internal soap
  * TODO: CR
  */
 public function ExecuteFromInternal($verifyInternal = TRUE)
 {
     if ($this->data['MSG_TYPE'] == "Publish" || $this->data['MSG_TYPE'] == "Execute") {
         // @TODO oc666: check this condition
         if (substr($this->data['REQUEST_ID'], 4, 2) == $this->data['FROM'] || $this->data['MSG_TYPE'] == "Execute") {
             $this->saveDB();
         } else {
             $this->saveTransactionsDB();
         }
         if (!isset($this->data['PHONE_NUMBER']) || $this->data['PHONE_NUMBER'] == NULL) {
             $this->data['PHONE_NUMBER'] = Application_Model_General::getFieldFromRequests('phone_number', $this->data['REQUEST_ID']);
         } else {
             if ($this->data['MSG_TYPE'] != "Publish") {
                 //				Application_Model_General::writeToLog($this->data);
             }
         }
     }
     $validate = false;
     $this->request->setAck('Inv03');
     //??
     if (!$verifyInternal || $this->request->InternalPostValidate()) {
         $this->request->setCorrectAck();
         if ($this->data['MSG_TYPE'] != "Publish" && $this->data['MSG_TYPE'] != "Execute") {
             $this->saveDB();
         }
         $validate = true;
     }
     $this->createResponse($validate);
     //create soap response and send it to provider
 }