<?php
/**
 *	Generated by miceCMS
 *	http://www.miceCMS.com/
 */
class plugin_editAction extends security_login {
	function action(){
		//接收参数并放入Session
		ModuleLimit(__CLASS__);
		global $conn;
		$plugin_id=$this->_getParam('plugin_id');
		$status=$this->_getParam('status');
		$hook=$this->_getParam('hook');
		$name=$this->_getParam('name');

		if($plugin_id)
		{
			$ins='内容已存在';
			$plugin=new model_Plugin();
			$plugin->setSubsection('WHERE plugin_id='.$plugin_id);
			if($status){
				$plugin->setIsopen(0);
				$exeresult='禁用此插件成功';
			}else{
				$plugin->setIsopen(1);
				$exeresult='启用此插件成功';
			}
			$results=$plugin->doUpdate();
			if(!$results){
				$exeresult='启用此插件失败';
			}

		}else{
			$ins='内容已不存在';
			$plugin=new model_Plugin();
			$plugin->setHook($hook);
			$plugin->setName($name);
			$plugin->setIsopen(1);
			$plugin->setOrderid(1);
			$results=$plugin->doInsert();
			if($results){
				$exeresult='启用此插件成功';
				$uid=$conn->Insert_ID();
			}else
				$exeresult='启用此插件失败';
		}

		

		$jsstring='Dialog.alert("'.$exeresult.'",function(){history.back(-1);});';
		MessageBox($jsstring);
		exit;
	}
}
?>