Ejemplo n.º 1
0
    public function pullDailyRecommendThreads($spaceId)
    {/*{{{*/
        $space = DAL::get()->find('space', $spaceId); 
        if($space->isNull())
        {
            $this->setErrorCode(328);
            return 0;
        }
        $firstLoginTime = '';
        $spaceexp= DAL::get()->find_by_userid('spaceexp', $space->user->id);
        if(false == $spaceexp->isNull())
        {
            $firstLoginTime = $spaceexp->firstLoginTime;
        }
        if(empty($firstLoginTime)
        || false == empty($firstLoginTime) && (XDateTime::hourDiff(XDateTime::valueOf($firstLoginTime),XDateTime::now()) > 24))
        {
            $proposalIds = ProposalClient::getInstance()->autoPullRecommends($space);
			error_log("[".XDateTime::now()."] ".$space->user->name."\n", 3, "/tmp/mobile_autopull.log");
            if (false == empty($proposalIds))
            {
                SpaceExpClient::getInstance()->createSpaceExp($space->user->id, XDateTime::now());
            } 
        } 
    }/*}}}*/
Ejemplo n.º 2
0
 public function ajaxGetNextRecommendThread($request, $response)
 {/*{{{*/
     header('Content-Type: application/json; charset=UTF-8');
     //判断是否推送的判断变量
     $isCanAutoPull = (false === empty($_COOKIE["userinfo"]["hosttype"]) 
         && 'Doctor' == $_COOKIE["userinfo"]['hosttype']) ;
     $cookie = new HdfCookie();
     $isSuccess = 0;
     if($isCanAutoPull 
         && (false === isset($_COOKIE['firstlogintime'])
         || (false == empty($_COOKIE['firstlogintime']) 
         && (XDateTime::hourDiff(XDateTime::valueOf($_COOKIE['firstlogintime']), XDateTime::now()) > 24))))
     {
         $auto = ThreadClient::getInstance()->autoPullRecommendThreads($this->_newUser);
         if ($auto)
         {
             $cookie->set("firstlogintime", XDateTime::now(), 7*24*3600);
             SpaceExpClient::getInstance()->createSpaceExp($this->_newUser->id, XDateTime::now());
             $isSuccess = 1;
         } 
     } 
     $unUnreadCaseCount = FlowClient::getInstance()->getUnReadCount($this->_newSpace->id);
     $callback = $request->callback;
     echo "\n".$callback.'(';
     echo Json::encode($unUnreadCaseCount);
     echo ');';
     //方便测试
     echo "\nisCanAuto:".$isCanAutoPull;
     echo "\nisSuccess:".$isSuccess;
     exit;
 }/*}}}*/
 private function canRecommend()
 {
     /*{{{*/
     $userClient = UserClient::getInstance();
     $isDoctor = 'Doctor' == $userClient->getSeed('hosttype');
     $firstlogintime = $userClient->getSeed('firstlogintime');
     $this->log->addDebug("isDoctor:" . (int) $isDoctor);
     $this->log->addDebug("firstlogintime:" . (int) $firstlogintime);
     return $isDoctor && (null === $firstlogintime || $firstlogintime && XDateTime::hourDiff(XDateTime::valueOf($firstlogintime), XDateTime::now()) > 24);
 }