token = $token; /** * 用户身份 */ $this->globalUserName = $this->GetUserNameByToken(); $this->globalUserRoleId = $this->GetUserRoleByToken(); /** * SVN配置文件相关 */ $this->globalAuthzContent = file_exists(SVN_AUTHZ_FILE) ? file_get_contents(SVN_AUTHZ_FILE) : ''; $this->globalPasswdContent = file_exists(SVN_PASSWD_FILE) ? file_get_contents(SVN_PASSWD_FILE) : ''; /** * 请求载体 */ global $requestPayload; $this->requestPayload = $requestPayload; /** * 数据库连接 */ $this->database = (new conn())->GetConn(); /** * svnadmin对象 */ $this->SVNAdminGroup = new \SVNAdmin\SVN\Group($this->globalAuthzContent, $this->globalPasswdContent); $this->SVNAdminHooks = new \SVNAdmin\SVN\Hooks($this->globalAuthzContent, $this->globalPasswdContent); $this->SVNAdminInfo = new \SVNAdmin\SVN\Info($this->globalAuthzContent, $this->globalPasswdContent); $this->SVNAdminRep = new \SVNAdmin\SVN\Rep($this->globalAuthzContent, $this->globalPasswdContent); $this->SVNAdminUser = new \SVNAdmin\SVN\User($this->globalAuthzContent, $this->globalPasswdContent); } /** * 根据token获取用户角色id */ final function GetUserRoleByToken() { if (!isset($this->token) || empty($this->token)) { return ''; } $arr = explode('.', $this->token); return $arr[0]; } /** * 根据token获取用户名称 */ final function GetUserNameByToken() { if (!isset($this->token) || empty($this->token)) { return ''; } $arr = explode('.', $this->token); return $arr[1]; } /** * 重新从authz文件中读取内容 * * 由于有些操作会更改authz文件内容且其它操作依赖这一实时结果 因此需要及时更新 */ final function UPdateAuthz() { $this->globalAuthzContent = file_exists(SVN_AUTHZ_FILE) ? file_get_contents(SVN_AUTHZ_FILE) : ''; } }