<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class poll_update2Action extends security_login {
	function action(){
		ModuleLimit(__CLASS__);
		$miceSession = new session();
		global $conn;
		$poll_id=$_POST['poll_id'];
		if($poll_id){
			$poll=new model_Poll();
			$poll->setSubsection('WHERE poll_id='.$poll_id);
			$results=$poll->doSelectOne();
		}

		$title=MiceFilterHtml($_POST['title']);
		$isdefault=$_POST['isdefault'];
		$orderid=$_POST['orderid'];
		$num=$_POST['num'];

		if($title==""){
			$jsstring='Dialog.alert("投票选项名称不能为空",function(){history.back(-1);});';
			MessageBox($jsstring);
			exit;
		}

		

		if($results)
		{
			$ins='内容已存在';
			$poll->setTitle($title);
			$poll->setIsdefault($isdefault);
			$poll->setOrderid($orderid);
			$poll->setNum($num);
			$results=$poll->doUpdate();
			if($results)
			{
				$exeresult='更新成功';
			}else{
				$exeresult='更新失败';
			}

		}else{
			$ins='内容已不存在';
			$poll=new model_Poll();
			$poll->setTitle($title);
			$poll->setPollcategoryId($miceSession->get('pollcategory_id'));
			$poll->setIsdefault($isdefault);
			$poll->setOrderid($orderid);
			$poll->setNum($num);
			$results=$poll->doInsert();
			if($results)
			{
				$exeresult='插入成功';	
			}else{
				$exeresult='插入失败';
			}
		}

		if($_POST['goon']==1){
			$jsstring='Dialog.alert(\''.$exeresult.'\',function(){window.location.href="'.MICE_URL.'admin.php/poll/edit2";window.event.returnValue = false;},300,100,"继续添加投票选项");';
			MessageBox($jsstring);
		}else{
			$jsstring='Dialog.alert(\''.$exeresult.'\',function(){window.location.href="'.MICE_URL.'admin.php/poll/index2/pollcategory_id/'.$miceSession->get('pollcategory_id').'";window.event.returnValue = false;},300,100,"返回投票选项列表");';
			MessageBox($jsstring);
		}

		exit;
	}
}
?>