_userPermissions)) { $rs = $this->_oauthRequest('user'); if (!$rs) { return false; } $this->_userPermissions = $rs['data']; } return in_array($permissionid, $this->_userPermissions); } /** * 获取当前用户的权限 */ public function getUserPermission() { if (is_null($this->_userPermissions)) { $rs = $this->_oauthRequest('user'); if (!$rs) { return array(); } $this->_userPermissions = $rs['data']; } return $this->_userPermissions; } /** * 获取访问ACTINO需要的权限 */ public function getAppPermission() { $parameters = array('x_action'=>$this->_action, 'x_controller'=>$this->_controller, 'x_module'=>$this->_module); $rs = $this->_oauthRequest('index', $parameters); if (!$rs) { return null; } $this->_userPermissions = $rs['data']['user_permissions']; return $this->_appPermissions = $rs['data']['app_permission']; } protected $_oauthConsumer; protected $_oauthApiSignMethod; protected $_aclUrl; protected function _oauthRequest($action, $parameters = null) { $accessToken = Zeed_OAuth_Util::parseParameters($_SESSION['admin.access_token']); $accessToken = new Zeed_OAuth_Token( $accessToken['oauth_token'], $accessToken['oauth_token_secret']); if (is_null($this->_oauthConsumer)) { $config = Zeed_Config::loadGroup('access'); $this->_oauthConsumer = new Zeed_OAuth_Consumer($config['appkey'], $config['appsecret']); $this->_oauthApiSignMethod = new Zeed_OAuth_Signature_HMACSHA1(); $this->_aclUrl = $config['acl_url']; } $request = Zeed_OAuth_Request::fromConsumerAndToken($this->_oauthConsumer, $accessToken, "GET", $this->_aclUrl.$action, $parameters); $request->signRequest($this->_oauthApiSignMethod, $this->_oauthConsumer, $accessToken); $response = $request->request(); if ($response === false || $response['code'] != 200) { return false; } $result = $response['body']; $result = json_decode($result, true); if (!is_array($result)) { return false; } return $result; } }