<?php
class jobAction extends security_normal {
	
	function action(){
		$miceSession = new session();
		if($miceSession->get('mu__userid')<1){
			$uid=0;
			$name='';
		}else{
			$uid=$miceSession->get('mu__userid');
			$name=$miceSession->get('mu__loginname');
		}

		$jobid=ceil($this->_getParamId(1));
		$article=new model_Article();
		$article->setSubsection('WHERE isvisible=0 AND type=\'article4\' AND article_id='.$jobid);
		$ArticleRS=$article->doSelectOne();
		if(!$ArticleRS){
			$jsstring='Dialog.alert("对不起,您查看的招聘岗位不存在或已经被删除",function(){history.back(-1);});';
			MessageBox($jsstring);
			exit;
		}

		if($ArticleRS->getIsremark()!=0){
			$jsstring='Dialog.alert("对不起,您查看的招聘岗位不允许在线提交简历",function(){history.back(-1);});';
			MessageBox($jsstring);
			exit;
		}

		global $conn;
		if($_POST){
			if($_POST['checkcode']<>$miceSession->get('checkcode')){
				$jsstring='Dialog.alert("验证码错误",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			if($_POST['name']==''){
				$jsstring='Dialog.alert("请填写姓名",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			$form=new model_Form();
			$form->setName($_POST['name']);
			$form->setUserId($uid);
			$form->setEmail(MiceFilterHtml($_POST['email']));
			$form->setTitle(MiceFilterHtml($_POST['title']));
			$form->setCreatedat(time());
			$form->setType('job');
			$form->setIp(GetRealIp());
			$form->setContent(MiceFilterQuote($_POST['content']));
			$results=$form->doInsert();

			if($results)
				$exeresult='提交成功';
			else
				$exeresult='提交失败';
			$jsstring='Dialog.alert(\'您的应聘信息已提交,请等待我们和您联系\',function(){window.location.href="'.MICE_URL.'";window.event.returnValue = false;},300,100,"提示信息");';
			MessageBox($jsstring);
			exit;
		}

		$editor='';
		//调用插件
		$plugin=new model_Plugin();
		$plugin->setSubsection('WHERE isopen=1 AND hook=\'editor_fast\' ORDER BY orderid ASC,plugin_id DESC');
		$plugins=$plugin->doSelectOne();
		include_once MICE_DIR.'includes/plugin.php';
		if($plugins){
			if(file_exists(MICE_DIR.'plugins/'.$plugins->getName().'/index.php')){
				include_once MICE_DIR.'plugins/'.$plugins->getName().'/index.php';
				add_filter('editor_fast', $plugins->getName());
				$editor=apply_filters('editor_fast',0);
				remove_filter('editor_fast', $plugins->getName());
			}
		}

		if($editor==''){
			$editor='<textarea id="MCEname" name="MCEname" rows="15" cols="80" style="width: 100%">MCEcontent</textarea>';
		}

		$editor=str_replace('MCEname','content',$editor);
		$editor=str_replace('MCEcontent','',$editor);

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign("name",$name);
		$smarty->assign("title",$ArticleRS->getTitle());
		$smarty->assign('editor',$editor);
		$smarty->assign("checkcode",MICE_URL.'index.php/checkcode');

		$filename = new getTPLFileName(__CLASS__);
		$tpl=$filename->TPLFileName;
		$smarty->display($tpl);
	}	
}
?>