예제 #1
0
 function getTicket($force)
 {
     if ($force) {
         $result = $this->m2mService->getM2MTicket();
         if (PEAR::isError($result)) {
             throw new Exception($result->getMessage(), $result->getCode());
         }
     }
     $ticket = $this->m2mDal->getM2MTicket($this->m2mService->accountId);
     return $ticket ? $ticket : $this->getTicket(true);
 }
예제 #2
0
 /**
  * Class constructor
  *
  * @return OA_Central_CurrencyFX()
  */
 function OA_Central_CurrencyFX()
 {
     parent::OA_Central_Common();
     $this->oSimpleFunctionCache = $this->createSimpleFunctionCache($this->oMapper, "getFXFeed", 43200);
 }
예제 #3
0
파일: Rpc.php 프로젝트: villos/tree_admin
 /**
  * A method to perform a call to the OAC XML-RPC server
  *
  * @param string $methodName The RPC method name
  * @param int    $authType   Type of required authentication, see constants
  * @param array  $aParams    Array of XML_RPC_Values
  * @return mixed The returned value or PEAR_Error on error
  */
 function call($methodName, $authType, $aParams = null, $recursionLevel = 0)
 {
     $aPref = $GLOBALS['_MAX']['PREF'];
     $oMsg = new XML_RPC_Message('oac.' . $methodName);
     $oMsg->remove_extra_lines = $this->remove_extra_lines;
     $aHeader = array('protocolVersion' => OA_DAL_CENTRAL_PROTOCOL_VERSION, 'ph' => OA_Dal_ApplicationVariables::get('platform_hash'));
     if ($authType & OA_DAL_CENTRAL_AUTH_M2M) {
         if (empty($this->oCentral)) {
             MAX::raiseError('M2M authentication used with a non M2M-enabled OA_Central object');
         }
         $aHeader['accountId'] = (int) $this->oCentral->accountId;
         $aHeader['m2mPassword'] = OA_Dal_Central_M2M::getM2MPassword($this->oCentral->accountId);
         if (empty($aHeader['m2mPassword']) || isset($GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId]) && $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] == true) {
             // No password stored, connect!
             $result = $this->oCentral->connectM2M();
             if (PEAR::isError($result)) {
                 return $result;
             }
             $aHeader['m2mPassword'] = $result;
         }
     }
     if ($authType & OA_DAL_CENTRAL_AUTH_SSO) {
         $aHeader['ssoUsername'] = $this->ssoUsername;
         $aHeader['ssoPassword'] = $this->ssoPassword;
     }
     if ($authType & OA_DAL_CENTRAL_AUTH_CAPTCHA) {
         $aHeader['ssoCaptcha'] = isset($_REQUEST['captcha-value']) ? $_REQUEST['captcha-value'] : '';
         $aHeader['ssoCaptchaRandom'] = isset($_REQUEST['captcha-random']) ? $_REQUEST['captcha-random'] : '';
     }
     $oMsg->addParam(XML_RPC_encode($aHeader));
     if (is_array($aParams)) {
         foreach ($aParams as $oParam) {
             $oMsg->addParam($oParam);
         }
     }
     OA::disableErrorHandling();
     $oResponse = $this->oXml->send($oMsg, OAC_RPC_TIMEOUT);
     OA::enableErrorHandling();
     if (!$oResponse) {
         return new PEAR_Error('XML-RPC connection error', OA_CENTRAL_ERROR_XML_RPC_CONNECTION_ERROR);
     }
     if ($oResponse->faultCode() || $oResponse->faultString()) {
         // Deal with particular response codes at Rpc level, avoiding endless recursion
         if (!$recursionLevel) {
             switch ($oResponse->faultCode()) {
                 case OA_CENTRAL_ERROR_PLATFORM_DOES_NOT_EXIST:
                     OA::disableErrorHandling();
                     $oSync = new OA_Sync();
                     $oSync->checkForUpdates();
                     OA::enableErrorHandling();
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel);
                 case OA_CENTRAL_ERROR_ERROR_NOT_AUTHORIZED:
                     if (!($authType & OA_DAL_CENTRAL_AUTH_M2M)) {
                         break;
                     } else {
                         // Go with OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID
                     }
                 case OA_CENTRAL_ERROR_M2M_PASSWORD_INVALID:
                     // OAP was asked to connect the account to get a password
                     // Set clear the password and retry (old password is in DB in case of problems with receiving new one)
                     $GLOBALS['OX_CLEAR_M2M_PASSWORD'][$this->oCentral->accountId] = true;
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel, true);
                 case OA_CENTRAL_ERROR_M2M_PASSWORD_EXPIRED:
                     $result = $this->_reconnectM2M();
                     if (PEAR::isError($result)) {
                         return $result;
                     }
                     return $this->call($methodName, $authType, $aParams, ++$recursionLevel);
             }
         }
         return new PEAR_Error($oResponse->faultString(), $oResponse->faultCode());
     }
     $ret = XML_RPC_decode($oResponse->value());
     // handling unknown server errors
     // this may happen due to difference in Java/PHP XML-RPC handling errors
     if (is_array($ret) && (isset($ret['faultCode']) || isset($ret['faultCode']))) {
         return new PEAR_Error('Unknown server error', OA_CENTRAL_ERROR_SERVER_ERROR);
     }
     return $ret;
 }