oSession = BxDolSession::getInstance(); $this->sErrorCode = 'oauth_err_code'; $this->sErrorMessage = 'oauth_err_message'; } static function isAuthorizedClient() { return (int)BxDolSession::getInstance()->getValue(self::$sSessionKeyAuthorized) == 1; } static function getAuthorizedClient() { return (int)BxDolSession::getInstance()->getValue(self::$sSessionKeyAuthorizedUser); } static function isAuthorizedOwner() { return (int)BxDolSession::getInstance()->getValue(self::$sSessionKeyAuthorizedOwner) == 1; } public function loadItems($aParams = array()) { if(empty($this->sKey) || empty($this->sSecret)) return MsgBox(_t('_adm_err_oauth_empty_key_secret')); $mixedResult = $this->authorize(); if($mixedResult !== true) return $this->onAuthorizeFailed($mixedResult); $aItems = $this->fetch($aParams); if(is_null($aItems)) return MsgBox(_t('_adm_err_oauth_cannot_read_answer')); else if(empty($aItems)) return MsgBox(_t('_Empty')); return $aItems; } public function doAuthorize() { if(empty($this->sKey) || empty($this->sSecret)) return MsgBox(_t('_adm_err_oauth_empty_key_secret')); $mixedResult = $this->authorize(); if($mixedResult !== true) return $this->onAuthorizeFailed($mixedResult); BxDolStudioInstallerUtils::getInstance()->checkModules(true); return $mixedResult; } protected function onAuthorizeFailed($mixedResult) { if(is_string($mixedResult)) return MsgBox($mixedResult); $bArray = is_array($mixedResult); if($bArray && !empty($mixedResult['redirect'])) { header('Location: ' . $mixedResult['redirect']); exit; } if($bArray && !empty($mixedResult['message'])) return MsgBox($mixedResult['message']); } protected function isAuthorized() { return self::isAuthorizedClient(); } protected function getAuthorizedUser() { return self::getAuthorizedClient(); } protected function unsetAuthorizedUser() { $this->oSession->unsetValue(self::$sSessionKeyToken); $this->oSession->unsetValue(self::$sSessionKeyAuthorized); $this->oSession->unsetValue(self::$sSessionKeyAuthorizedUser); $this->oSession->unsetValue(self::$sSessionKeyAuthorizedOwner); } protected function isServerError($aResult) { return isset($aResult[$this->sErrorCode]) && isset($aResult[$this->sErrorMessage]); } } /** @} */