public function before($context)
 {
     $spaceUserName = WebUtil::getSpaceUserName($context->request);
     $space = SpaceClient::getInstance()->getSpaceByUserName($spaceUserName);
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     $user = DAL::get()->find('user', $userId);
     if ($space->isNull()) {
         header('Location: http://www.haodf.com');
         exit;
     }
     if (empty($userId) || $space->user->id != $userId && false == $user->isAdmin()) {
         $msg = rawurlencode('你没有权限操作!');
         header('Location: ' . $space->getUrl() . 'index/showmessage?msg=' . $msg);
         exit;
     }
 }
예제 #2
0
 public function __construct($request, $response)
 {
     /*{{{*/
     parent::__construct($request, $response);
     $response->imgTimestamp = BeanFinder::get('configs')->imgTimestamp;
     $spaceUserName = WebUtil::getSpaceUserName($request);
     $this->space = SpaceClient::getInstance()->getSpaceByUserName($spaceUserName);
     if ($this->space->isNull()) {
         header('Location: http://www.haodf.com');
         exit;
     }
     if ($this->space->isHospitalFaculty()) {
         $requestUri = $_SERVER['REQUEST_URI'];
         header('Location: http://' . URL_PREFIX . $this->space->user->name . '.haodf.com' . $requestUri);
         exit;
     }
     $this->user = NullEntity::create();
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     if ($userId) {
         $this->user = DAL::get()->find('user', $userId);
     }
     $response->space = $this->space;
     $response->user = $this->user;
     //未登录 或者 站外链接访问 skips
     if ($this->user->isNull() || false == $request->isQueryFromHDF()) {
         $this->skips($response);
     }
     $this->initModules($request, $response);
     $this->spaceIsLogin = $this->isSpaceLogin();
     $response->spaceIsLogin = $this->spaceIsLogin;
     $response->isSpaceUser = $this->isSpaceUser();
     $response->unreadCaseCount = $this->getUnReadCaseCount();
     if ($this->space->modulecase->isNull()) {
         SpaceModuleCaseClient::getInstance()->initModuleCase($this->space);
     }
     $this->accessLog();
     $configs = BeanFinder::get('configs');
     $response->imgUrl = $configs->imgUrl;
     $response->spaceStyleId = $request->view_style_id ? $request->view_style_id : $this->space->getSpaceStyleId();
     $response->_window_id = $request->window_id;
     $response->spaceBaseUrl = URL_PREFIX . $this->space->userName . '.haodf.com';
     $response->title = $this->space->name . '大夫个人网站';
     $response->scripts = array();
     $response->spaceHits = $this->getSpaceHits($request);
     $response->goodDoctorList = $this->getGoodDoctorListOf2013();
     $response->patientGoodDoctorList = $this->getPatientGoodDoctorListOf2013();
 }
    public function before($context) 
    {
    	$spaceUserName = WebUtil::getSpaceUserName($context->request);
    	$space = SpaceClient::getInstance()->getSpaceByUserName($spaceUserName);
        /**
         * 测试医院下所有space只能在办公区访问 
         *
         **/
    	$userId = UserClient::getInstance()->getCheckedSeed('id');
    	$user = DAL::get()->find('user', $userId);
        $hdferUserNames = array('verygoodman', 'willowliu', 'dvsj', 'yangshiqi');
        if(in_array($user->name, $hdferUserNames) == false && $space->host instanceof Doctor && $space->host->hospitalfaculty->hospital->isInnerTestHospital() && false == RequestDelegate::isOfficeIp())
        {
    		header('Location: http://www.haodf.com');
			exit;
    	}
    }
 public function before($context)
 {
     $spaceUserName = WebUtil::getSpaceUserName($context->request);
     $space = SpaceClient::getInstance()->getSpaceByUserName($spaceUserName);
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     $user = DAL::get()->find('user', $userId);
     if ($space->isNull()) {
         header('Location: http://www.haodf.com');
         exit;
     }
     $auditor = DAL::get()->find_by_userid('auditor', $userId);
     if (empty($userId) || $space->user->id != $userId && $userId != 6 && FollowupAssistantClient::getInstance()->hasAssistRights($userId, $space->id) == false && $auditor->isNull()) {
         $msg = rawurlencode('你没有权限操作!');
         header('Location: ' . $space->getUrl() . 'index/showmessage?msg=' . $msg);
         exit;
     }
 }
예제 #5
0
    public function __construct($request, $response) 
    {/*{{{*/
        parent::__construct($request, $response);
        $this->clearWrongCookie();
        $this->_spaceUserName = WebUtil::getSpaceUserName($request);
    	if ($this->_spaceUserName == 'probe') {
            //构造函数里边,必须得exit才能跳转
            $response->exitJump('http://www.haodf.com', 301);
		}
		$userId = UserClient::getInstance()->getCheckedSeed('id');
        if ($userId)
        {
		    $this->_newUser = DAL::get()->find('user',$userId);
            $this->_newUserId = $this->_newUser == null?null:$this->_newUser->id;
        }
        else
            $this->_newUser = new NullEntity();

        $this->fix4thief($response);        

    	if ($this->_spaceUserName)
			$this->_newSpace = SpaceClient::getInstance()->getSpaceByUserName($this->_spaceUserName);
		else
			$this->_newSpace = new NullEntity();

        if ($this->_newSpace->host instanceof Doctor)
        {
            $this->_newSpace->host->doctorIsDead();
        }

        if ($this->_newSpace->isNull() || $this->_newSpace->host->isNull()) {
            //构造函数里边,必须得exit才能跳转
            $response->exitJump('http://www.haodf.com', 301);
		}
        if($this->_newUser->id == $this->_newSpace->id)
        {
            $this->adminIsLogin = true;
        }
		
        $this->skips($response);

		//如果是admin登录,则会模拟成空间所属的医生登录
		//注意:在判断是否是真正的医生登录时,要取cookie或session中的值
		//问题:现在的管理员仅指admin一个用户,而不是具有管理员角色的人
		if ($this->_newUser->isAdmin())
		{
			$this->_newUser = $this->_newSpace->user;
            $response->adminIsLogin = $this->_adminIsLogin = true;
		}
		$this->_spaceIsLogin = (($this->_newUser->isNull() == false) && (strtolower($this->_spaceUserName) == strtolower($this->_newUser->name))) ? true : false;
		
		$this->_spaceBaseUrl = URL_PREFIX.$this->_spaceUserName.'.haodf.com';
		$response->spaceBaseUrl = $this->_spaceBaseUrl;
		$this->_spaceStyleId = $request->view_style_id ? $request->view_style_id : $this->_newSpace->styleId;
		$response->spaceStyleId = $this->_spaceStyleId;
		
		$this->initAllMenu();
		$mainMenu = $this->initMainMenu($request);
		$response->spaceMainMenu = $mainMenu;
		
		if ($this->_newSpace->modulecase->isNull())
			SpaceModuleCaseClient::getInstance()->initModuleCase($this->_newSpace);

		$response->spaceIsLogin = $this->_spaceIsLogin;
        $response->newSpace = $this->_newSpace;
        $response->newUser = $this->_newUser;
        
        $response->forceCheckLogin = (isset($_SERVER['HTTP_HOST'])) ? "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] : "";
        
        $response->_is_ajax = $request->is_ajax;
		$response->_window_id = $request->window_id;
		
        if ($this->_newSpace->isDoctor())
        {
            $response->title = $this->_newSpace->name.'大夫个人网站';
        }
        else
        {
        	$response->title = $this->_newSpace->name.'网站';
        	$response->_my_template_dir = 'templates/hospitalfaculty';
        }
        $response->spaceUserModule = '';
        $response->spaceModule = '';
        if (false == isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strpos($_SERVER['HTTP_X_REQUESTED_WITH'], 'XMLHttpRequest') === false)
        {
            $response->spaceHits  = $this->getSpaceHits();
        }

        $this->_log();
        $configs = BeanFinder::get('configs');
        $response->imgUrl = $configs->imgUrl;
    }/*}}}*/
    public function myNearHospitalList($request, $response)
    {/*{{{*/
        $longitude = $request->longitude;
        $latitude = $request->latitude;
        $distance = array();
        $options = HospitalClient::getInstance()->getHospitalMapPoint($longitude, $latitude);
        foreach ($options as $option)
        {
            $distance[$option['id']] = WebUtil::getDistanceByLongitudeAndLatitude($latitude, $longitude, $option['_s']['latitude'], $option['_s']['longitude']);
        }
        asort($distance);

        $distance = array_slice($distance, 0, 20, true);
        $hospitalList = DAL::get()->find('hospital', array_keys($distance));
        $response->hospitalInfos = HospitalClient::getInstance()->groupHospitalByCategory($hospitalList);
        $response->distance = $distance;
        $response->title = "我附近的大医院_好大夫在线";
    }/*}}}*/
 public static function isNeedRedirctToMobile()
 {/*{{{*/
     $agent = isset($_SERVER['HTTP_USER_AGENT']) ? getenv('HTTP_USER_AGENT') : getenv('HTTP_X_UCBROWSER_UA');
     return WebUtil::isSmartMobileAgent($agent) && false == isset($_COOKIE['ttw']);
 }/*}}}*/