<?php

/*
*	Copyright VeryIDE,2007-2010
*	http://www.veryide.com/
*
*	$Id: veryide.setting.php,v2 19:47 2008-2-21 Lay $
*/

require '../../include/loader.php';

html_start("系统设置 - VeryIDE");
?>

<!--body start-->

	<?php
		
	require_once(VI_ROOT."class/setting.php");	
	
	//模块ID
	$appid = getgpc('appid');
	
	//配置地址
	$self = VI_ROOT.'module/'.$appid.'/config.php';
	
	//加载导航
	include('include/naver.setting.php');
	
	if( $appid && file_exists( $self ) && require( $self ) ){
	
		//模块配置
		$app = $_G['module'][$appid];
		
		//权限名称
		$func = "sys-setting-".$app['model'];
	
		//检查权限
		System :: check_func( $func, false );
		
		$_GalSet = new Setting(VI_ROOT.'module/'.$appid.'/setting.php' , VI_ROOT.'module/'.$appid.'/setting.xml' , $appid);
		
		if( $_GET["action"]=="update" && !empty($_POST) ){
			
			if( $_GalSet->save('POST') ){
				
				//连接数据库
				System :: connect();
					
				//写入日志
				System :: insert_event($func,time(),time());
				
				//关闭数据库
				System :: connect();
				
				echo '<div id="state">成功修改模块配置，新配置将立即生效</div>';
				
			}else{
				
				echo "<div id='state' class='failure'>保存模块配置失败！请检查 ./module/".$appid."/setting.php 是否有读写权限</div>";
				
			}
			
		}elseif( $_GalSet -> writable() == FALSE ){
			echo "<div id='state' class='failure'>请检查 ./module/".$appid."/setting.php 是否有读写权限</div>";	
		}
		
		$form = $_GalSet->transform();
		
		?>
		
		<script type="text/javascript">
		//if( parent.parent.Mo.store.model == "modern" ){
			Mo("#wrapper").attr({"class":"snugly"});
		//}
		</script>
	
		<div id="box">
			<form method="post" action="?appid=<?php echo $appid;?>&action=update" mode="edit" verify="true">
	
			<table cellpadding="0" cellspacing="0" class="form">
	
			<?php
	
			echo $form;		
	
			?>
			<tr class="nobr">
				<td><strong></strong></td>
				<td>
					<input type="submit" name="" value="保存配置" class="submit" />
				</td>				
			</tr>
	
			</table>
	
			</form>
		</div>
		
		<?php
		
	}else{
	
		echo "<div id='state' class='failure'>模块不存在或已删除！请检查 module/".$appid."/ 目录是否有效</div>";
	
	}
	
    ?>

<!--body end-->

<?php html_close();?>