<?php

/*

		用户主题设置

*/

//载入全局配置和函数包
require_once(dirname(__FILE__)."/../include/global.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $Project["charset"];?>" />
<title>更换主题 - Powered By VeryIDE</title>

<?php

echo loader_style(array(VI_BASE."style/dialog.css"),$Project["charset"],$Project["version"]);

echo loader_script(array(VI_BASE."js/mo.js",VI_BASE."js/core.js",VI_BASE."js/library.js",VI_BASE."js/form.js"),$Project["charset"],$Project["version"]);

?>

</head>

<body>

	<div id="wrapper">
	
	<?php
	
	//菜单处理
	$action = GetQuery("action");
	$jump = GetQuery("jump");
	
	//mysql open
	reader_mysql();
	
	//动作处理
	switch ($action){
		
		case "update":
		
			//检查权限
			$func = "sys-account-mod";
			checker_func($func);
			
			//配置
			$config = $_POST["config"];
			$config = format_json( fix_json( $config ) );
				
			//更新数据
			$sql="update ".VI_DBMANPRE."admin set config='".$config."' where id=".$_SESSION["Manager"]["id"];			
			mysql_query($sql,$mysql);
			
			//缓存系统用户
			cache_table('system',$mysql,VI_DBMANPRE."admin",'<option value=\'{table:id}\'>{table:account}</option>');
					
			//写入日志
			event_insert($mysql,$func,time(),time(),"用户设置，更改用户偏好。");				
			
			$Project["message"]="成功修改用户偏好!";
			
			echo '<div id="state">你刚刚更改了个人偏好，请刷新查看最新效果：<input name="submit" onclick=\'parent.location.reload(true)\' type="button" class="submit" value="刷新此页面" /></div>';
		
		break;
		
	}
	
	//
	$sql="select * from ".VI_DBMANPRE."admin where id=".$_SESSION["Manager"]["id"];
	$result=mysql_query($sql,$mysql);
	
	$Project["queries"]++;
	
	if(mysql_num_rows($result)==1){
		$row=mysql_fetch_assoc($result);
		
		//配置
        $config = fix_json( $row["config"] );
		
	}else{
		$Project["message"]="未找到指定用户!";
	}
	
	//mysql close
	reader_mysql(true);
	
	?>

	<?php
	
	//显示权限状态
	checker_func("sys-account-mod",true);
		
	?>

	<form action="?" method="post">

	<table cellpadding="0" cellspacing="0" class="form">

		<tr><td colspan="2" class="section"><strong>圣诞气氛</strong></td></tr>

		<tr>
			<td width="60"><strong>圣诞帽子：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="config[ui-head]" value="Y">带上帽子</label>
				<label><input type="radio" class="radio" name="config[ui-head]" value="N">不带帽子</label>
			</td>
		</tr>

		<tr>
			<td><strong>雪花效果：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="config[ui-snow]" value="Y">雪花效果</label>
				<label><input type="radio" class="radio" name="config[ui-snow]" value="N">禁用效果</label>
			</td>
		</tr>

		<tr><td colspan="2" class="section"><strong>服务扩展</strong></td></tr>

		<tr>
			<td><strong>云输入法：</strong></td>
			<td>
				<label><input type="radio" class="radio" name="ext-input" value="" onclick="cfg.setValue(this.checked,this.name,this.value,function(S){$('config').value = S;});">禁用服务</label>

				<label><input type="radio" class="radio" name="ext-input" value="wubi" onclick="cfg.setValue(this.checked,this.name,this.value,function(S){$('config').value = S;});">五笔输入</label>

				<label><input type="radio" class="radio" name="ext-input" value="pinyin" onclick="cfg.setValue(this.checked,this.name,this.value,function(S){$('config').value = S;});">拼音输入</label>

				<label><input type="radio" class="radio" name="ext-input" value="yingwen" onclick="cfg.setValue(this.checked,this.name,this.value,function(S){$('config').value = S;});">英文输入</label>
			</td>
		</tr>
		
		<tr class="nobr">
			<td><strong></strong></td>
			<td>
				<input type="submit" name="Submit" value="保存更改" class="submit" />
				<input type="hidden" name="action" id="action" value="update" />
			</td>
		</tr>

	</table>


	<script type='text/javascript'>
		
		Mo("input[name='config[ui-head]']").value("<?php echo $config["ui-head"];?>");
		Mo("input[name='config[ui-snow]']").value("<?php echo $config["ui-snow"];?>");
		
	</script>

	</form>

	</div>
	
</body>
</html>