public function before($context)
 {/*{{{*/
     if(false == $this->isInspector($context) 
         && false == $this->isUserSelf($context)
         && false == $this->isDoctor($context)
         && false == $this->isDefaultUserAttachment($context))
     {
         MsgHtml::msg('您没有权限查看该附件');
     }
 }/*}}}*/
	public function receiveProofSMS($request, $response)
	{/*{{{*/
		$orderId = $request->id;
		$order = DAL::get()->find('BookingOrder', $orderId);
        $proposal = $order->notification->proposal;
		DBC::requireEquals($order->userid, $this->user->id, '您无权操作别人的订单!');
			
		$now = XDateTime::now("Y-m-d H:i:s");
		$before1Schedule = $order->schedule->addDay(-1)->setHour("16")->setMinute("00");
		$before2Schedule = $order->schedule->addDay(-2)->setHour("20")->setMinute("00");
		//在加号日期两天之前显示的内容
		if($now < $before2Schedule)
		{
			$response->message = "<div align='left'>暂时不能领取加号凭证,<br/>请您在".date('Y-m-d H:i', strtotime($before2Schedule))."至".date('Y-m-d H:i', strtotime($before1Schedule))."到此页面领取加号凭证短信,若操作有困难,也可在".date('Y-m-d', strtotime($before1Schedule))."日9点半至16点致电客服协助您完成操作,客服电话".BookingOrder::BU_PHONE_1."</div>";
			MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/proposal/showbookinglist', array('delay' => 10, 'button' => 'back'));
			exit();
		}
		$response->order = $order;
		$response->proposal = $proposal;

	}/*}}}*/
	
	if(empty($adviceContent)) {
		MsgHtml::msg('请填写变更信息', '', array('button'=>'back'));
	}
	
	$content = $doctor->hospitalfaculty->hospital->name.' '.$doctor->hospitalfaculty->name.' 人员变更信息'.chr(13).chr(10);
	$content .= $request->adviceContent;
	
	$result = UserClient::getInstance()->addUserAdvice('意见建议', $content, $doctorId);
	if( $result )
	{
		MsgHtml::msg('信息发送成功,感谢对好大夫在线的支持。', 'http://www.'.URL_PREFIX.'haodf.com', array());
	}
	else
	{
		MsgHtml::msg('信息发送失败, 烦请稍后再试, 或使用其它方法联系好大夫网站, 谢谢!', '', array('button'=>'back'));
	}
}
$doctors = $doctor->hospitalfaculty->doctors;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<link href="http://i1.hdfimg.com/css/base.css?2012052401" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript" src="http://i1.hdfimg.com/js/jquery-1.4.2.min.js"></script>
<title>站内信</title>
<style>
	.siteInforBox{ width:478px; margin:30px auto 0 auto; background:url(images/siteInfor04.gif) repeat-y; font-size:14px; padding:0px;}
	.siteInforBoxTop{ background:url(images/siteInfor02.gif) no-repeat left top; height:9px; width:478px;}
	.siteInforBoxBottom{ background:url(images/siteInfor03.gif) no-repeat left bottom; height:9px; width:478px;}
	public function addDoctorCommentPost($request, $response)
	{/*{{{*/
		$dcId = $request->commentid;
		$dcpContent = $request->dcpContent;
        $doctorComment = DoctorCommentClient::getInstance()->getDoctorComment($dcId);
		if(mb_strlen($dcpContent, 'gbk') > 500)
		{
			MsgHtml::msg('你发表的内容超过500字限制', $doctorComment->getUrl(), array('delay' => '10', 'button' => 'back'));
		}

        Crumb::ensure(DoctorCommentClient::getInstance()->genCommentCrumbKey(), $request->crumb, self::TTL);
        $user = $this->curUser;
        if ($user->isNull())
        {
            $user = DoctorComment::getGuestUser();
        }

        $gid = UserClient::getInstance()->checkGuest();

        try
        {

            $res = DoctorCommentPostClient::getInstance()->addDoctorCommentPost($doctorComment, $user, $dcpContent, XIpLocation::getIp(), $gid);
        }
        catch(BizException $ex)
        {
            MsgHtml::msg($ex->getMessage(), $doctorComment->doctor->getUrl(), array('delay' => '10', 'button' => 'close'));
        }
        $this->cleanUrlCache($doctorComment->getUrl());
        $this->cleanUrlCache($doctorComment->doctor->getUrl());
    	$response->setRedirect($doctorComment->getUrl()."?from=1"); 
	}/*}}}*/
    public function deleteAttach($request, $response)
	{/*{{{*/
		$id = $request->id;
        $attachement = DAL::get()->find('patientattachment', $id);
        if($attachement->isNull())
        {
            MsgHtml::msg("你操作的附件不存在");
        }
        if($this->user->id != $attachement->user->id)
        {
            MsgHtml::msg("你无权操作别人的附件");
        }
		$res= BingLiClient::getInstance()->doDelete($id);
        return self::DIRECT_OUTPUT;
	}/*}}}*/
    public function receiveProofSMS($request, $response)
    {/*{{{*/
        $ref = DAL::get()->find('DoctorPatientRef', $request->refid);
        if($ref->isNull())
        {
            header('Location: '.$this->_newSpace->url);
            return;
        }
        
        $orderId = $request->id;
        $order = DAL::get()->find('BookingOrder', $orderId);
        DBC::requireEquals($order->userid, $this->_newUser->id, '您无权操作别人的订单!');
            
        $now = XDateTime::now("Y-m-d H:i:s");
        $before1Schedule = $order->schedule->addDay(-1)->setHour("16")->setMinute("00");
        $before2Schedule = $order->schedule->addDay(-2)->setHour("20")->setMinute("00");
        //在加号日期两天之前显示的内容
        if($now < $before2Schedule)
        {
            $response->message = "<div align='left'>暂时不能领取加号凭证,<br/>请您在".date('Y-m-d H:i', strtotime($before2Schedule))."至".date('Y-m-d H:i', strtotime($before1Schedule))."到此页面领取加号凭证短信,若操作有困难,也可在".date('Y-m-d', strtotime($before1Schedule))."日9点半至16点致电客服协助您完成操作,客服电话".BookingOrder::BU_PHONE_1."</div>";
            MsgHtml::msg($response->message, $ref->url, array('delay' => 10, 'button' => 'back'));
            exit();
        }
        $response->setRedirect($ref->url);

    }/*}}}*/
 public function announce($request, $response) 
 {/*{{{*/
     $hospitalId = Codec::getInstance()->decodeId($request->hospitalid);
     $hospital = DAL::get()->find('hospital', $hospitalId);
     if($hospital->isNull())
     {
         MsgHtml::msg("医院不存在");exit;
     }
     $response->hospital = $hospital;
 }/*}}}*/
<?php
require_once dirname(__FILE__).'/../init.php';
$request = new Request();

$hospitalFacultyId = Codec::getInstance()->decodeId($request->getRequest('id'));
if ($hospitalFacultyId <= 0){ 
	MsgHtml::msg("未知科室");
	exit;
}

//科室信息
$hospitalFaculty = DAL::get()->find('HospitalFaculty', $hospitalFacultyId);
//$hospitalFacultyInfo = $Moo->Model->Hdf_ViewHospitalFaculty->rowDetail($hospitalFacultyId);

//接收提交参数
$from    = $request->getRequest('from');
$info    = $request->getRequest('info');
$url     = $request->getRequest('url');
$fname   = $request->getRequest('fname');
$tel     = $request->getRequest('tel');
$mobtel  = $request->getRequest('mobtel');
$qq      = $request->getRequest('qq');
$msn     = $request->getRequest('msn');
$email   = $request->getRequest('email');
$footing = $request->getRequest('footing');
$confirm = $request->getRequest('confirm');
$result = 0;
$user = UserClient::getInstance()->getCurrentUser();

$temp = array(0=>'科室医生',1=>'患者', 2=>'其他');
Example #9
0
<?php
$base = dirname(__FILE__);
require_once($base.'/../init.php');

$isIndex = 1;
$tmpRequest = new Request();
$doctorId = $tmpRequest->doctor_id;

$isLogin = UserClient::getInstance()->isLogin();
if ($isLogin) {
	$user = UserClient::getInstance()->getCurrentUser();
	if ($user->hasSpace()) {
		if (Codec::getInstance()->decodeId($doctorId) != $user->space->host->id) {
			MsgHtml::msg('您已经是注册医生了,现在将跳转到您的个人网站', "http://{$user->name}.haodf.com");
		} else {
			header("Location: http://{$user->name}.haodf.com");
		}
		exit();
	}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>注册医生帐户_介绍</title>
<link href="http://i1.hdfimg.com/css/css.css?1303386395" rel="stylesheet" type="text/css" />
<link href="http://i1.hdfimg.com/css/frame.css?20131224" rel="stylesheet" type="text/css" />
<link href="http://i1.hdfimg.com/css/inside.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<?php
require_once dirname(__FILE__).'/../init.php';
$request = new Request();


$hospitalId = Codec::getInstance()->decodeId($request->getRequest('id'));
if ($hospitalId <= 0){ 
	MsgHtml::msg("未知医院");
	exit;
};

//医院信息
$hospital = DAL::get()->find('Hospital', $hospitalId);

if(false == $hospital->isNull() && $hospital->isActivated == 0)
{
    $jumpUrl = 'http://www.'.URL_PREFIX.'haodf.com/info/dissociatedoctornotice.php';
    header("Location: $jumpUrl");
}


//接收提交参数
$from    = $request->getRequest('from');
$info    = $request->getRequest('info');
$url     = $request->getRequest('url');
$fname   = $request->getRequest('fname');
$tel     = $request->getRequest('tel');
$mobtel  = $request->getRequest('mobtel');
$qq      = $request->getRequest('qq');
$msn     = $request->getRequest('msn');
$email   = $request->getRequest('email');
	private function realFinish($request, $response)
	{
		$user = UserClient::getInstance()->getCurrentUser();
		$response->userName = '';
		if ($user->hasSpace() == false)
		{
			MsgHtml::msg('医生注册失败, 请重新尝试, <a href="http://www.haodf.com/suggestion/suggestion">或与我们联系</a>');
		}
		else
		{
			$response->space = $user->space;
			$response->userName = $user->name;
			try
			{
				$tplname = "doctor.reg.success";
				$userId = $user->id;
				$datas = array();
				$datas['doctorname'] = $user->realName;
				$datas['username'] = $user->name;
				//站内消息
				StationLetterClient::getInstance()->sendMsgByTpl($tplname, Auditor::ADMIN_USER_ID, array($userId), $datas);
				//邮件
				$email = $user->email;
				EmailClient::getInstance()->sendByTpl($tplname, $email, $datas, true);
				
				$operators = array();
				$operators['zxh']="张旭海";
				$operators['lyp']="刘义平";
				$operators['dh']="代红";
				$operators['ll']="刘柳";
				$operators['liu']="刘柳";
				$operators['ccm']="陈超美";
				$operators['test']="内部测试";
				$operators['sjp']="史建平";
				$operators['ylf']="杨利锋";
				$operators['cf']="崔芳";
				
				//内部注册特殊处理
				$userPhone = $user->phone;
				foreach($operators as $key=>$value)
				{
					if(strpos($userPhone,$key) !== false)
					{
						$userPhone = trim(str_replace($key,'',$userPhone));
						$userPhone = str_replace('()',' ',$userPhone);	
						$userPhone = str_replace('( )',' ',$userPhone);	
						$dd = array();
						$dd['phone'] = $userPhone;
						$dd['spaceRemarks1'] = $user->spaceRemarks1."电话拜访";
						$dd['spaceRemarks2'] = $user->spaceRemarks2.$value;
						$userId = UserClient::getInstance()->modifyInfoNew($userId, $dd);
						
						$tplname = "doctor.reg.success.2";
						break;
					}
					//防刷新时,发送电话拜访的短信
					if(strpos($user->spaceRemarks2, $value) !== false)
					{
						$tplname = "doctor.reg.success.2";
						break;
					}
				}
				//暂时只发自注册医生的短信通知
				if($tplname != "doctor.reg.success.2")
				{
					//短信
					$phone = $user->mobile;
					SMSClient::getInstance()->sendSMSByTplName($tplname, array($phone), $datas, SMSLog::OPT_TYPE_DOCTOR_REG_SUCCESS, '', true);
				}
			}
			catch(Exception $ex)
			{
				//暂时忽略异常
			}
		}
	}
	public function postTopic($request, $response)
	{
		$groupIds = $request->groupIds;
		if(!$groupIds)
		{
			$response->message = '没有选择话题所在的组!';
			MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/post', array('delay' => 6, 'button' => 'back'));
			return false;
		}
		$title = $request->title;
		$content = preg_replace("/<\/?a[^>]*>/i", "", $request->content);
		if(XString::cntrim($title) == '' || XString::cntrim($content) == '')
		{
			$response->message = '话题标题和内容都不能为空!';
			MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/post', array('delay' => 6, 'button' => 'back'));
			return false;
		}
		$groups = DAL::get()->find('regroup', $groupIds);
		foreach($groups as $group)
		{
			if($group->reboard->isNull() == false)
			{
				$member = ForumClient::getInstance()->getMemberByUserIdAndGroupId($this->user->id, $group->id);
				if($member->isNull() == false && $member->isForbiddened())
				{
					$response->message = '您的发言没有成功,可能是已被禁止发言!服务电话:'.HdfPhoneNumber::PHONE_FENZHEN;
					MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/index', array('delay' => 6, 'button' => 'back'));
					return false;
				}
				ResidentEvilClient::getInstance()->createTopic($group->space, $group->reboard, $this->user, $title, $content);
			}
		}
		$response->message = '话题发表成功!';
		MsgHtml::msg($response->message, 'http://'.URL_PREFIX.'passport.haodf.com/mypatient/index', array('delay' => 6, 'button' => 'back'));
	}
{
    MsgHtml::msg('请填写您的手机,以便与您联系。', '', array('button'=>'back'));
}

if( '' == $email )
{
    MsgHtml::msg('请填写您的邮箱,以便与您联系。', '', array('button'=>'back'));
}
elseif (!Xstring::isEmail($email))
{
    MsgHtml::msg('邮件格式错误,请正确填写您的邮箱。', '', array('button'=>'back'));
}
$verifyOk = Captcha::verify($request->door, XIpLocation::getIp(), 'dcapply', $user->id, $request->token);
if($verifyOk != 1)
{
    MsgHtml::msg('验证码输入错误', '', array('button'=>'back'));
}
$recipients = "*****@*****.**";
$title = "医生基本信息 (".date("y-m-d H:i").")";
$content = "";
$content .= "来自 ".$_SERVER['REMOTE_ADDR']." 的用户发送了一条医生信息, 内容如下:\n";
if ($from == 'search') $content .= "从搜索来的\n";
$content .= "所提交的医院科室: <a href='".$hospitalFaculty->getUrl()."' target=\"_blank\">".$hospitalFaculty->hospital->name.$hospitalFaculty->name."</a>\n";
$content .= "----------------------------------------------------------------------------\n";
$content .= "姓名: ".$name."\n";
$content .= "性别: ".(($sex) ? '男' : '女')."\n";
if ($birthday) $content .= "出生日期: ".$birthday."\n";
if ($duty) $content .= "行政职务: ".$duty."\n";
if ($appellation) $content .= "职称: ".$appellation."\n";
if ($teachappellation) $content .= "教学职称: ".$teachappellation."\n";
if ($shanchang) $content .= "擅长: ".$shanchang."\n";
	public function sosPost($request, $response)
	{
		$tel = $request->tel;
		$time = $request->time;
        $isAjax = $request->isAjax;
		$confirm = $request->confirm;
        if($isAjax)
        {
            $adviceContent = mb_convert_encoding(trim($request->adviceContent),'gbk','utf-8');
            $clientInfo = mb_convert_encoding($request->clientInfo, 'gbk', 'utf-8');
        }
        else
        {
            $adviceContent = trim($request->adviceContent);
            $clientInfo = $request->clientInfo;
        }

        $msg = null;
		
		if( empty($adviceContent) )
		{
            $msg  = '您还没有简要描述您使用好大夫在线所遇到的困难或需要的帮助,请填写后再点击提交';
            if(false == $isAjax)
            {
                MsgHtml::msg($msg, '', array('button' => 'back' ));
                exit;
            }
		}
        else
        {
            $title = "空间求助 (" . date ( "y-m-d H:i" ) . ")";
            $content = "";
            $content .= "来自 " . XIpLocation::getLocationArea() . '[' . XIpLocation::getIp() . "] 的用户发送了一条空间求助, 内容如下:\n";
            $content .= $adviceContent ."\n";
            if (! $this->_newSpace->isConfirmed()) {
                $content .= "<font color=red>注意: 该用户未认证(" . date ( 'y-m-d H:i:s', time() ) . "之前)!!!</font>\n";
            }
            $content .= "所提交的空间: <a href=\"http://" . $this->_newSpace->userName . ".haodf.com\" target=\"_blank\">" . $this->_newSpace->host->name . "</a>\n";
            if($request->id)
            {
                if($request->type == DoctorPatientRef::DOCTORPATIENTREF_TYPE) 
                {
                    $sourceUrl = DoctorPatientRef::getStaticUrl($this->_newSpace->userName, $request->id);
                    $content .= "<a href= '{$sourceUrl}'  target='_blank' > 来源链接 </a>\n";
                }
                else if($request->type == DoctorPatientRef::THREAD_TYPE) 
                {
                    $sourceUrl = Thread::getStaticUrl($this->_newSpace->userName, $request->id);
                    $content .= "<a href= '{$sourceUrl}'  target='_blank' > 来源链接 </a>\n";
                }
            }
            $content .= "----------------------------------------------------------------------------\n";
            $content .= "联系电话: " . $tel . "\n";

            if ($time) {
                $content .= "方便联系的时间: " . $time . "\n";
            }
            $content .= "----------------------------------------------------------------------------\n";
            $content .= "发送时间: " . date("Y-m-d H:i");
            $content .= "----------------------------------------------------------------------------\n";
            $content .= "用户端信息: \n" . $clientInfo;
            UserClient::getInstance()->addUserAdvice('空间求助', $content, $this->_newSpace->user->id);

            $msg = '信息发送成功,感谢对好大夫在线的支持,管理员稍后为您处理遇到的问题,处理后我们会发送站内信通知您,请继续浏览网站信息';
            if(false == $isAjax)
            {
                MsgHtml::msg($msg, $this->_newSpace->getUrl());
            }
        }
        $response->msg = $msg;
	}
 private function isPatientSignin($space, $patientId)
 {/*{{{*/
     $patientSignin = FlowClient::getInstance()->getOrdinaryPatientSignin($space->id, $patientId);
     $patientSignin = DAL::get()->find('patientSignin',$patientSignin->id,true);
     if(false == $patientSignin->isNull())
     {
         //如果还在审核中,不再重复提交
         if($patientSignin->isUnaudited()) {
             MsgHtml::msg("您还有正在审核中的诊后报道,审核通过后才能再次提交", $space->getUrl());
             return true;
         }
     }
     else
     {
         return false;
     }
 }/*}}}*/
    public function addUserAdvice($request, $response)
    {/*{{{*/
        $tmp = UserClient::getInstance()->checkProfanity(strip_tags($request->suggestion));
        $suggestion= $tmp['CONTENT'];

        if (!empty($suggestion)) {	

            $content = "";
            $content .= "用户".$this->user->name." 发送了一条意见或建议, 内容如下:\n";
            $content .= "----------------------------------------------------------------------------\n";

            $content .= $suggestion."\n\n";
            $content .= "电话:".$this->user->mobile."\n";
            $content .= "E-Mail: ".$this->user->email."\n";
            $content .= "姓名: ".$this->user->realName."\n";

            $content .= "----------------------------------------------------------------------------\n";
            $content .= "发送时间: ".XDateTime::now();

            UserClient::getInstance()->addUserAdvice('随访条款', $content, $this->user->id);
            $forward = "http://www.".URL_PREFIX."haodf.com/#notRedirect";
            $msg = "<div style='margin:10px;height:60px;'>
                <div style='float:left; margin:20px 0px 0px 10px; font-weight: bold;height:30px;'>
                提交意见成功!</div></div>";
            $msg .= "<div style='margin:10px 0px;border-top:1px dashed #cccccc;height: 1px;overflow:hidden;'></div>";
            $msg .= "本页面将在3秒内自动跳转到网站首页,如果没有跳转";
            MsgHtml::msg($msg, $forward);
        }
    }        /*}}}*/
    private function _payForPresent($request, $response)
    {/*{{{*/
        $presentOrder = DAL::get()->find('presentorder', $request->orderId);
        if($presentOrder instanceof NullEntity)
        {
            MsgHtml::msg('不存在该购买行为', '', array('delay' => 10, 'button' => 'back'));
        }

        if($this->user->id != $presentOrder->user->id)
        {
            MsgHtml::msg('不能支付别人的订单哦亲', '', array('delay' => 10, 'button' => 'back'));
        }

        $res = ScoreClient::getInstance()->payForPresent($presentOrder->user->id, $presentOrder->space->id, $presentOrder->id);

        if(Account::PAY_RESULT_SUCC == $res)
        {
            $response->setRedirect($presentOrder->successUrl());
        }
        else
        {
            MsgHtml::msg('不够支付呀', '', array('delay' => 10, 'button' => 'back'));
        }
    }/*}}}*/