public function __construct($request, $response)
 {
     /*{{{*/
     parent::__construct($request, $response);
     $clients = array('auditorClient', 'threadCateClient', 'userClient', 'spaceClient', 'doctorClient', 'hospitalClient', 'hospitalFacultyClient', 'PatientClient', 'DoctorPatientPostClient', 'inspectClient');
     foreach ($clients as $client) {
         $this->{$client} = new ClientProxy($client);
     }
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     if ($userId) {
         $this->curUser = DAL::get()->find('user', $userId);
     } else {
         $this->curUser = new NullEntity();
     }
     $response->curUser = $this->curUser;
     $response->staticUrl = 'http://i1.hdfimg.com/in/case';
     $response->leftWidth = '40%';
     //$response->leftWidth = '43%';
     $response->controller = $request->controller;
     $response->action = $request->action;
     $response->showContent = $request->showContent;
     $this->user = $response->user;
     $this->curInspector = $response->curInspector;
     $this->auditor = $response->auditor;
     if (false == $this->auditor instanceof Auditor) {
         $auditor = $this->curInspector->getAuditorEntity4auditfront();
         $this->auditor = $auditor;
     }
     $response->args = array();
     $response->isAjax = $request->ajax_status;
 }
 public function checkPassword($request, $response)
 {/*{{{*/
     $err = '';
     $password = $request->password;
     if ($password == '')
     {
         $err = '对不起,您的密码输入有误。请输入正确的密码。';
     }
     $nowAction = $request->parentaction ? $request->parentaction : 'index';
     $nowAction = $nowAction == 'showorderlist' ? $nowAction.'?type=5' : $nowAction;
     if(empty($err))
     {
         $user = UserClient::getInstance()->checkPassword($this->_newSpace->user->name, $password, time()+1200);
         if ($user->isNull())
         {
             $err = '对不起,您的密码输入有误。请输入正确的密码。';
         }
         else
         {
             $response->setRedirect($response->router->urlfor('adminpayment/'.$nowAction));
             return true;
         }
     }
     $response->setRedirect($response->router->urlfor("adminpayment/inputpassword?err=$err&parentaction=".$nowAction));
 }/*}}}*/
   public function doSuggestion($request, $response)
   {/*{{{*/
       $suggestion = iconv("utf8", "gbk", $request->suggestion);
       $contactInfo = iconv("utf8", "gbk", $request->contactInfo);
       if ($suggestion == '' || $suggestion == '请填写您在使用中遇到的问题(目前暂时不提供疾病咨询服务)')
       {
            echo '{"res":"failure", "msg":"请填写您在使用中遇到的问题!"}';
            return self::DIRECT_OUTPUT;
       }
       if ($contactInfo == '' || $contactInfo == '手机或邮箱')
       {
            echo '{"res":"failure", "msg":"请填写您的联系方式!"}';
            return self::DIRECT_OUTPUT;
       }
       $from = $request->from;

       $content = "来自 ".$from." 的用户(触屏版)发送了一条意见或建议, 内容如下:\n";
       $content .= "----------------------------------------------------------------------------\n";
       $content .= $suggestion."\n\n";
       $content .= "联系方式: $contactInfo\n";
       $content .= "----------------------------------------------------------------------------\n";
       $content .= XDateTime::now()->toString();
       $userId = 0;
       $result = UserClient::getInstance()->addUserAdvice('意见建议', $content, $userId);
       if ($result)
       {
            echo '{"res":"success"}';
        }
        else
        {
            echo '{"res":"failure", "msg":"对不起,信息提交失败!"}';
        }
        return self::DIRECT_OUTPUT;
   }/*}}}*/
	public function before($context)
	{
        $userId = UserClient::getInstance()->getCheckedSeed('id');      
        $user = DAL::get()->mustFind('user', $userId);
        $inspector = DAL::get()->find_actived('inspector', $user);
        $hasClaimPaymentPower = $inspector->isInRenLingHuiKuanGroup();
        DBC::requireTrue($hasClaimPaymentPower, '您没有认领汇款权限');
	}
 public function __construct($request, $response)
 {
     parent::__construct($request, $response);
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     $this->curOperatorUser = DAL::get()->mustFind('user', $userId);
     $response->curOperatorUser = $this->curOperatorUser;
     $this->inspector = DAL::get()->find_actived('inspector', $this->curOperatorUser);
     $response->inspector = $this->inspector;
 }
 public function __construct($request, $response)
 {
     parent::__construct($request, $response);
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     if ($userId) {
         $this->_newUser = DAL::get()->find('user', $userId);
     } else {
         $this->_newUser = new NullEntity();
     }
 }
    public function before($context)
    {
    	$userId = UserClient::getInstance()->getCheckedSeed('id');
    	$user = DAL::get()->find('user', $userId);
    	if($user->isNull())
    	{
    		header('Location: http://m.haodf.com/touch');
			exit;
    	}
    }
	public function ajaxSetRead($request, $response)
	{
		$str = '';
		if (UserClient::getInstance()->isLogin() && $request->msgid)
		{
			$data = array('UserId' => $this->user->id, 'MsgId' => $request->msgid);
			StationLetterClient::getInstance()->setMsgRead($data['UserId'], $data['MsgId']);	
			$str = "²Ù×÷³É¹¦";
		}
		$response->callBack = $request->callback;
		$response->msg = $str;
	}
 public function __construct($request, $response) 
 {
     parent::__construct($request, $response);
     $configs = BeanFinder::get('configs');
     $response->imgUrl = $configs->imgUrl;
     $userId = UserClient::getInstance()->getCheckedSeed('id');
     if ($userId)
         $this->_newUser = DAL::get()->find('user',$userId);
     else
         $this->_newUser = new NullEntity();
      
     $response->newUser = $this->_newUser;
 }
    public function __construct($request, $response) 
    {
        parent::__construct($request, $response);
        
        $response->_debugger = new Debugger();
        $response->_start = $response->_debugger->getTimeStamp();
        
        $userId = UserClient::getInstance()->getCheckedSeed('id');
		$this->user = DAL::get()->find('user', $userId);
		$this->tester = DAL::get()->find_by_userid('tester', $userId);
        $response->user  = $this->user;
		$response->tester = $this->tester;
		
		$response->preMsg = $request->preMsg;
    }
 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;
     }
 }
 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;
     }
 }
    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 modifyPost($request, $response)
 {
     /*{{{*/
     $this->myProjectOperator->checkAdminAuthOrQuit('update');
     $projectOperatorId = $request->projectOperatorId;
     $userName = $request->userName;
     $user = UserClient::getInstance()->getByUserName($userName);
     DBC::requireTrue($user instanceof User, "User {$userName} 不存在.");
     $params = array();
     $params['userId'] = $user->id;
     $params['name'] = $request->name;
     $params['role'] = $request->role;
     $params['status'] = $request->status;
     $params['projectOrgId'] = $request->projectOrgId;
     ProjectOperatorClient::getInstance()->modifyProjectOperator($projectOperatorId, $params, $this->myProjectOperator->id);
     $preMsg = "操作员 {$projectOperatorId} 信息修改成功";
     $response->setRedirect($response->router->urlfor('projectoperatormgr/modify', array('preMsg' => $preMsg, 'projectOperatorId' => $projectOperatorId)));
 }
 public function createConf($request, $response)
 {/*{{{*/
     $orderid = $request->sId;
     $curOwner = $this->currentOwner;
     $adminTelephone = DAL::get()->find_by_ownerid('AdminTelephone',$curOwner->id);
     $order = DAL::get()->find('telorder', $orderid, true);
     $executer = $order->executer;
     DBC::requireFalse($executer->isNull(), '会议室里没有医生');
     $phones = array($adminTelephone->telselected, 
         $order->patient->getPatientExt()->phone1, 
         $order->patient->getPatientExt()->phone2,
         $executer->getSpaceExt()->phone1, 
         $executer->getSpaceExt()->phone2, 
         $executer->getSpaceExt()->phone3);
     $admin = UserClient::getInstance()->getCurrentUser();
     DBC::requireTrue($admin instanceof User ,'请先登录吧~');
     $teleconfId = MeetingClient::getInstance()->createMeeting($order->id, $phones, $admin->id, $admin->name, $order->getMeetingDuration());
     $response->setRedirect('/paymentfront/telorder/orderexecutenew?orderid='. $orderid);
 }/*}}}*/
    public function __construct($request, $response) 
    {/*{{{*/
        parent::__construct($request, $response);
		
        $response->controller = $request->controller;
        $response->action = $request->action;

        if ($_SERVER['HTTP_HOST'] == 'wenda.health.msn.com.cn') 
        {
            $imageUrl = 'https://wenda.health.msn.com.cn/partner';
        }
        else
        {
            $imageUrl = 'http://i1.hdfimg.com/partner';
        }
        $response->imageUrl = $imageUrl;
        
        $scheduleImgsArray = Schedule::$imgsArray;
       	$scheduleColorArray = array('普通' => 'normal', '专家' => 'expert', '专科' => 'special', '特需' => 'unique', 
       						 '会诊' => 'consultation', '夜间' => 'night', '其他' => 'other');
       	
       	$response->scheduleImgsArray = $scheduleImgsArray;
       	$response->scheduleTimeArray = array('上午', '下午', '夜间');
       	$response->scheduleTimeArray1 = array('上', '下', '夜');
       	$response->scheduleColorArray = $scheduleColorArray;
       	
       	$keys = array('DoctorCount','HospitalCount');
		$response->configInfo = DoctorClient::getInstance()->getConfigInfo($keys);

        $this->_newUser = UserClient::getInstance()->getCurrentUser();
        $this->_newSpace = new NullEntity();
        if(false == $this->_newUser->isNull())
        {
            if($this->_newUser->hasSpace())
            {
                $this->_newSpace = DAL::get()->find('space', $this->_newUser->id);
            }
        }
        $response->_newSpace = $this->_newSpace;
        $response->newUser = $this->_newUser;
        $response->_newUser = $this->_newUser;
    }/*}}}*/
 public function checkPhoneForTourist($request, $response)
 {/*{{{*/
     $buyerPhone = $request->buyerPhone;
     $userIds = UserClient::getInstance()->getIdsByUserPhone('user', $buyerPhone);
     $users = DAL::get()->find('user', $userIds);
     $userNames = array();
     foreach($users as $key => $value)
     {
         $userNames[] = $value->name;
     }
     if(empty($userNames))
     {
         echo 'fail';
         return parent::DIRECT_OUTPUT; 
     }
     else
     {
         $response->userNames = $userNames;
     }
 }/*}}}*/
	public function __construct($request, $response){
		//如果出现$user, $ssUser,则改为$newUser
		$userId = UserClient::getInstance()->getCheckedSeed('id');
        if($request->userId != null)
        {
            $userId = $request->userId;
        }
		if ($userId)
		    $this->_newUser = DAL::get()->find('user',$userId);
        else
            $this->_newUser = new NullEntity();
            	
        $response->newUser = $this->_newUser;
        
        $configs = BeanFinder::get('configs');
        $response->zixunBaseUrl = $configs->zixunBaseUrl;
        $response->imgBaseUrl = $configs->imgUrl;
		$response->domain = $request->getRequest('domain', URL_PREFIX.'zixun.haodf.com');
        $response->askSpace = AskSessionInfo::getBindSpace();
	}
    public function __construct($request, $response) 
    {/*{{{*/
        parent::__construct($request, $response);

        $userId = UserClient::getInstance()->getCheckedSeed('id');      
        $this->curUser = new NullEntity();
        $this->currentOwner = new NullEntity();
        if ($userId)
        {
            $this->curUser = DAL::get()->find('user', $userId);
    	    DBC::requireFalse($this->curUser->isNull(),"没有这个用户");
            if (false == $this->curUser->isNull())
            {
                $this->currentOwner = TelOwnerClient::getInstance()->createOwner($this->curUser);
            }
        }
        $response->curUser = $this->curUser;
        $response->currentOwner = $this->currentOwner;

    }/*}}}*/
 public function update($request, $response)
 {
     $id = $request->id;
     //被修改的userid
     $userInfo = $request->data;
     //被修改的userid
     //获取当前操作用户id
     $user = UserClient::getInstance()->getCurrentUser();
     $userInfo['modiferid'] = $user->id;
     $updateUser = DAL::get()->find('user', $id);
     $valueUserMobile = isset($userInfo['mobile']) ? UserClient::getInstance()->getSpaceByUserMobile($userInfo['mobile'], $id) : '';
     if (isset($userInfo['mobile']) && $userInfo['mobile'] && false == XString::isMobile($userInfo['mobile'])) {
         $msg = "您填写的手机号码不合要求,请修改后重新提交";
     } else {
         if ($updateUser->hasConfirmedSpace() && $updateUser->space->isDoctor() && isset($userInfo['mobile']) && $valueUserMobile) {
             $msg = "此手机号码已经绑定了注册医生,请重新确定手机号";
         } else {
             if ($updateUser->hasSpace() && $userInfo['realName']) {
                 //自动更新space上冗余的spacehostname
                 SpaceClient::getInstance()->setProperties($id, array('name' => $userInfo['realName']));
             }
             $userId = UserClient::getInstance()->modifyInfoNew($id, $userInfo);
             if ($userId) {
                 $msg = "操作成功了 ";
             } else {
                 $msg = "操作失败了 ";
             }
         }
     }
     if (DoctorComment::hasRightToUpdateUserContent($this->inspector->id)) {
         //获取被操作的用户
         $operationedUser = DAL::get()->find('User', $request->id);
         $logId = S3LogClient::getInstance()->add($this->inspector, $operationedUser->getLogable()->action(UserLog::ACTION_ADMIN_CONTENT, $request->adminContent));
     }
     $url = $response->router->urlfor('user/showuserdetail', array('id' => $id, 'msg' => $msg));
     $response->setRedirect($url);
 }
 public function auth($request, $response)
 {
     /*{{{*/
     $userName = $request->field1;
     $password = $request->field4;
     $userToken = $request->bk2;
     if (false == empty($userName) && false == empty($password)) {
         $user = UserClient::getInstance()->checkPassword($userName, $password);
         if ($user->isNull()) {
             echo "系统错误,请联系技术人员!!!!";
             exit;
         } else {
             if (false == isset($_COOKIE['bk']) || $userToken != $_COOKIE['bk']) {
                 if (@setcookie('bk', $userToken, 0, '/', 'haodf.com')) {
                     $_COOKIE['bk'] = $userToken;
                 }
             }
             $ip = RequestDelegate::getIp();
             PrivilegeClient::getInstance()->bindUser($user->id, $userToken, $ip);
             echo "成功";
             exit;
         }
     }
 }
	public function _update($request, $response) {
		if ($request->confirm) {
			$title = $request->title;
			$id = ZhuantiTopicClient::getInstance()->update(array(
				'id' => $request->id, 
				'title' => $request->title,
				'content' =>$request->getUnSafeData('content'),
				'url' => $request->url,
				'doctorId' => $request->doctorId,
			    'img'=>$request->imgId
            ));	
            if (isset($_FILES['headimage']) && $_FILES['headimage']['tmp_name'] != '') {
                $doctor = DAL::get()->find('Doctor', $request->doctorId);
                $userId = $doctor->hasSpace() ? $doctor->space->user->id : 0;
                if ($userId != 0) {
                    $imgId = TuClient::getInstance()->uploadImage($_FILES['headimage']);
                    UserClient::getInstance()->updateHeadImage($userId, $imgId);
                }
            }
			$msg = '更新成功';
			$url = $response->router->urlfor('topic/edit', array ('id' => $request->id, 'msg' => $msg,'zhuantiid'=>$request->zhuantiid));
            $response->setRedirect($url);
		} 
		$topic = DAL::get()->find('topic', $request->id);   
		if($topic->doctorId != 0){
            $doctor = DAL::get()->find('doctor', $topic->doctorId);
            $headImageId = $doctor->hasSpace() ? $doctor->space->user->headImage : '';
            if (empty($headImageId) == false) {
                $response->headImageUrl = TuClient::getInstance()->getThumbnailUrl($headImageId, 200, 200, TuClient::TYPE_ZOOM);
            }
		    $response->doctor = $doctor;
		}
		$response->zhuanti = DAL::get()->find('zhuanti', $request->zhuantiid);      
	    $response->topic = $topic;
        $response->msg = $request->msg;
	}
 public function updatePost($request, $response)
 {
     /*{{{*/
     //dodo::psq
     $trustIndex = $request->getRequest('trustIndex', 0);
     $commentDoctorId = $request->getRequest('commentDoctorId', 0);
     $punishDay = $request->getRequest('punishDay', 0);
     $remark = $request->reason;
     $this->checkDates($trustIndex, $punishDay, $remark, $commentDoctorId);
     $user = UserClient::getInstance()->getCurrentUser();
     $commentDoctor = DAL::get()->find('commentdoctorext', $commentDoctorId);
     $punishEndTime = $this->getPunishEndTime($commentDoctor, $punishDay);
     $remarkOfDoctor = "医生信用值由<font color='red' >" . $commentDoctor->trustIndex . "</font>改成<font color='red'>" . $trustIndex . "</font>;" . ($punishDay > 0 ? "点评入口操作:惩罚时间到<font color='red'>" . $punishEndTime . "</font>" : "") . ($punishDay < 0 ? "点评入口操作:<font color='red'>打开点评口</font>" : ";") . "<br>管理员备注:<font color='red'>" . $remark . "</font>";
     $isRole = $this->checkRole($commentDoctor, $request->trustIndex);
     if ($isRole == false) {
         $response->setRedirect("/commentdoctor/edit?id=" . $commentDoctorId . "&msg=" . urlencode('更新失败,没有权限修改信用值'));
         return false;
     }
     $id = CommentDoctorExtClient::getInstance()->modify($commentDoctorId, $user, $remark, $trustIndex, $punishEndTime, $request->needevidence);
     if ($id) {
         S3LogClient::getInstance()->add($this->inspector, $commentDoctor->getLogable()->action(CommentDoctorLog::ACTION_MODIFY_DOCTORINFO, $remarkOfDoctor));
         $response->setRedirect("/commentdoctor/edit?id={$id}&msg=" . urlencode('更新成功'));
     }
 }
 /**
     * @brief 重置密码
     * @author meihao
     * @exampleUrl 
     *
     * @Param $userId
     * @Param $password
     * @Param $rePassword
     *
     * @Returns   
  */
 public function resetPassWord($applyId, $password, $rePassword)
 {/*{{{*/
     $user = DAL::get()->find('user', $applyId);
     if($password == '')
     {
         $this->setErrorCode(823);
         return 0;	
     }
     if ($password != $rePassword)
     {
         $this->setErrorCode(824);
         return 0;
     }
     if (!preg_match("/^[0-9a-zA-Z]{4,16}$/", $password))
     {
         $this->setErrorCode(8251);
         return 0;
     }
     if($this->isSimplePWD($password, $user->name))
     {
         $this->setErrorCode(825);
         return 0;
     }
     UserClient::getInstance()->updatePassword($applyId, $password);
     $this->content = array('message' => '修改成功');
 }/*}}}*/
    public function askOtherPeople($request, $response)
    {/*{{{*/
		UserClient::getInstance()->logout();
		$host_user_id = $request->getRequest('host_user_id', 0);
		$response->setRedirect('/hzhospitalthread/ask.htm?host_user_id='.$host_user_id);
	}/*}}}*/
										
									</td>
								</tr>
								<tr>
									<td width="10%" align="right"></td>
									<td width="90%" class="gray">医生身份核实将基于真实姓名   
									&nbsp;&nbsp;<a href="http://www.haodf.com/passport/register.php">患者注册、咨询入口</a>
									<?php if(!empty($realName)){ ?> &nbsp;&nbsp;&nbsp;<a href="http://www.haodf.com/passport/dspace_intro.php">我不是<?=$realName?>,我也是医生,我要注册我的个人网站</a> <?php } ?>
									</td>
								</tr>
								<tr>
									<td width="10%" align="right"></td>
									<td width="90%" height="20" background="http://i1.hdfimg.com/passport/images/dotline.gif" style="background-repeat: repeat-x; background-position: center;"></td>
								</tr>
							</tbody>
							<?php if (!UserClient::getInstance()->isLogin()) { ?>
							<tbody>
								<tr>
									<td width="10%" align="right"><img src="http://i1.hdfimg.com/passport/images/jiantou.gif" width="12" height="12" class="jiantou" /></td>
									<td width="90%">密码:</td>
								</tr>
								<tr>
									<td width="10%" align="right"></td>
									<td width="90%"><input type="password" name="password"  onchange="checkpwd1();" id="password" size="16" maxlength="16" alt="密码:4-16/英文数字/有空格/下划线/有全角/怪字符"  value="<?=$password?>" />
									<label id="chk_password"></label></td>
								</tr>
								<tr>
									<td width="10%" align="right"></td>
									<td width="90%" class="gray">(4~16位,英文、数字均可)
									<span id="simpleHarm" class="font12 blue" >密码过于简单不能注册
										 <div id="showHarmContent" style="display: none;">
 public function ajaxPostSos($request, $response)
 {
     /*{{{*/
     $content = mb_convert_encoding(trim($request->content), 'gbk', 'utf-8');
     $clientInfo = mb_convert_encoding($request->clientInfo, 'gbk', 'utf-8');
     if ($content) {
         $adviceContent = $this->space->getAdviceContent($content, $clientInfo, $request->type, $request->id);
         $isSuccess = UserClient::getInstance()->addUserAdvice('空间求助', $adviceContent, $this->space->user->id);
         if ($isSuccess) {
             $msg = '信息发送成功,感谢对好大夫在线的支持,管理员稍后为您处理遇到的问题,处理后我们会发送站内信通知您,请继续浏览网站信息';
             echo '{"res":"success", "msg":"' . $msg . '"}';
         }
     } else {
         echo '{"res":"failure", "msg":"您还没有简要描述您使用好大夫在线所遇到的困难或需要的帮助,请填写后再点击提交"}';
     }
     return self::DIRECT_OUTPUT;
 }
 /**
     * @brief 医生提出导出数据请求
     * @author meihao
     * @exampleUrl http://dev.mobile-api.haodf.com/doctorapi/patientclub_postExportRequest?userId=1&email=11&xdoc=1
     *
     * @Param $userId  用户id
     * @Param $email   邮箱地址
     *
     * @Returns   
  */
 public function postExportRequest($userId, $email)
 {/*{{{*/
     if(empty($email))
     {
         $this->setErrorCode(817);
         return 0;
     }
     if(!Xstring::isEmail($email))
     {
         $this->setErrorCode(818);
         return 0;
     }
     $user = DAL::get()->find('user', $userId);
     if($user->isNull())
     {
         $this->setErrorCode(107);
         return 0;
     }
     $source = "客户端数据导出";
     $content = "用户名:".$user->name."\n邮箱:".$email."\n";
     $id = UserClient::getInstance()->addUserAdvice($source, $content, $user->id);
     if(empty($id))
     {
         $this->setErrorCode(816);
         return 0;
     }
     $this->content = $id;
 }/*}}}*/
 /** 患友会投诉**/
 public function ajaxComplaint($request, $response)
 {
     /*{{{*/
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') || strpos($_SERVER['HTTP_USER_AGENT'], 'Baiduspider')) {
         return false;
     }
     $topicUrl = $request->topicUrl;
     $messageId = $request->messageId;
     $floor = $request->floor;
     $isAjax = $request->isAjax;
     $adviceContent = trim($request->adviceContent);
     $complaintType = trim($request->complaintType);
     if ($isAjax) {
         $complaintType = mb_convert_encoding($complaintType, 'gbk', 'utf-8');
         $adviceContent = mb_convert_encoding($adviceContent, 'gbk', 'utf-8');
     }
     $content = "";
     $content .= "来自 " . XIpLocation::getLocationArea() . '[' . XIpLocation::getIp() . "] 的用户发送了一条患友会投诉, 内容如下:\n";
     $content .= "类型:" . $complaintType . "\n";
     $content .= "投诉内容:" . $adviceContent . "\n";
     $content .= "所提交的话题:<a href='" . $topicUrl . "' target='_blank'>点击查看</a>\n";
     $content .= "所提交的回复ID:" . $messageId . "\n";
     $content .= "所在楼:" . $floor . "楼\n";
     $content .= "所提交的空间: <a href=\"http://" . URL_PREFIX . $this->space->userName . ".haodf.com\" target=\"_blank\">" . $this->space->host->name . "</a>\n";
     $content .= "----------------------------------------------------------------------------\n";
     $content .= "提交人:" . $this->user->name . "(" . $this->user->id . ")\n";
     $content .= "发送时间: " . date("Y-m-d H:i") . "\n";
     $content .= "----------------------------------------------------------------------------\n";
     $content .= "用户端信息: \n" . $_SERVER['HTTP_USER_AGENT'];
     UserClient::getInstance()->addUserAdvice('评论投诉', $content, $this->user->id);
     return parent::DIRECT_OUTPUT;
 }
 public function add($request, $response)
 {
     /*{{{*/
     $user = UserClient::getInstance()->getCurrentUser();
     $assistant = Inspector::getInspector($user);
     $nickname = $request->nickname;
     $err = '';
     if (empty($nickname)) {
         $err = '您还未填写昵称名';
     } else {
         $assistantNickname = DAL::get()->find_by_nickname('assistantnickname', $nickname);
         if ($assistantNickname->isNull()) {
             $nicknameAudit = DAL::get()->find_by_assistantid_and_status('AssistantNicknameAudit', $assistant->id, AssistantNicknameAudit::WAITTING_AUDIT);
             if (false == $nicknameAudit->isNull()) {
                 $err = '您提交的昵称申请正在审核中';
             } else {
                 $assistantNickname = DAL::get()->find_by_assistantid('assistantnickname', $assistant->id);
                 if (false == $assistantNickname->isNull()) {
                     $err = '您已经绑定过昵称,请勿重新申请';
                 } else {
                     $assistantNicknameAuditId = AssistantNicknameClient::getInstance()->applyNickname($assistant, $nickname);
                     $err = '您成功提交医生助理昵称申请';
                     $assistantNicknameAudit = DAL::get()->find('assistantnicknameaudit', $assistantNicknameAuditId);
                     S3LogClient::getInstance()->add($assistant, $assistantNicknameAudit->getLogable()->action(4, ''));
                 }
             }
         } else {
             if ($assistantNickname->isBind()) {
                 $err = '您申请的昵称已经被使用,请重新申请';
             } else {
                 $nicknameAudit = DAL::get()->find_by_assistantnicknameid_and_status('AssistantNicknameAudit', $assistantNickname->id, AssistantNicknameAudit::WAITTING_AUDIT);
                 $nicknameAudit2 = DAL::get()->find_by_assistantid_and_status('AssistantNicknameAudit', $assistant->id, AssistantNicknameAudit::WAITTING_AUDIT);
                 if (false == $nicknameAudit->isNull()) {
                     if ($nicknameAudit->assistant->id == $assistant->id) {
                         $err = '您已经申请过昵称,您之前申请的昵称为:' . $assistantNickname->nickname;
                     } else {
                         $err = '您申请的昵称已经有其他人申请(正在审核),请重新申请或稍后重试';
                     }
                 } else {
                     if (false == $nicknameAudit2->isNull()) {
                         $err = '您提交的昵称申请正在审核中';
                     } else {
                         $assistantNicknameAuditId = AssistantNicknameClient::getInstance()->applyNickname($assistant, $nickname);
                         $err = '您成功提交医生助理昵称申请';
                         $assistantNicknameAudit = DAL::get()->find('assistantnicknameaudit', $assistantNicknameAuditId);
                         S3LogClient::getInstance()->add($assistant, $assistantNicknameAudit->getLogable()->action(4, ''));
                     }
                 }
             }
         }
     }
     $response->setRedirect($response->router->urlfor('nicknameaudit/applynickname', array('err' => $err)));
     $response->err = $err;
 }