<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>互动社区&nbsp;&gt;&nbsp;会员管理&nbsp;&gt;&nbsp;分配权限
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=User.userlist" class="nolink">会员列表</a>
				<a href="index.php?r=SiteSet.userset" class="link">属性设置</a>
				<a href="index.php?r=User.honourlist" class="link">会员头衔</a>
				<a href="index.php?r=SiteSet.experienceset" class="link">会员经验</a>
				<a href="index.php?r=User.forumroleimg" class="link">管理员身份勋章</a>
				<a href="index.php?r=User.albumlist" class="link">会员相册</a>
				<a href="index.php?r=User.listphotoframe" class="link">会员相框</a>
				<a href="index.php?r=User.msglist" class="link">会员消息</a>
				<a href="index.php?r=SiteSet.msgboxset" class="link">信箱设置</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent">
					<form id="UserForm" action="index.php?r=user.usermenu" method="post">
					<input type="hidden" name="action" value="do"/>
					<input type="hidden" name="data[User][id]" value="<!--{$user.id}-->"/>
					<input type="hidden" name="returnParams" value="<!--{$returnParams}-->"/>
					<table width="100%" cellpadding="0" cellspacing="0" border="0">
						<tr>
							<td>
								<b>后台角色</b> [<span style="color:blue;cursor:pointer; background:none; display:inline; padding:0px;" onClick="changeCmsRole(false)">撤销角色</span>]<br>
								<input type="radio" value="2" id="cms_role" name="data[User][cms_role]" onclick="changeCmsRole(true)" <!--{if $user.cms_role==2}--> checked="checked" <!--{/if}-->>后台管理员<br>
							</td>
							<td>
								<!--{foreach from=$menuList item=item}-->
									<!--{if $item.parent_id == null}-->
									<br/><input type="checkbox" name="menu[]" id="menu<!--{$item.id}-->" value="<!--{$item.id}-->" forum_menu_flag="<!--{$item.forum_menu_flag}-->" onclick="selectSubmenu(this)" <!--{if $item.user_menu_id != null}-->checked<!--{/if}-->/><!--{$item.menu_name}--><br/>
									<!--{/if}-->
									<!--{foreach from=$menuList item=submenu}-->
										<!--{if $submenu.parent_id == $item.id}-->
										<input type="checkbox" name="menu[]" value="<!--{$submenu.id}-->" forum_menu_flag="<!--{$item.forum_menu_flag}-->" parent_id="<!--{$item.id}-->" onclick="selectParentMenu(this)" <!--{if $submenu.user_menu_id != null}-->checked<!--{/if}-->/><!--{$submenu.menu_name}-->&nbsp;&nbsp;
										<!--{/if}-->
									<!--{/foreach}-->
								<!--{/foreach}-->
							</td>
							<td class="nowidth"></td>
						</tr>
						<tr>
							<td>
								<b>论坛角色</b> [<span style="color:blue;cursor:pointer; background:none; display:inline; padding:0px;" onClick="changeForumRole(false)">撤销角色</span>]<br>
								<input type="radio" value="1" name="data[User][forum_role]" onclick="changeForumRole(true)" <!--{if $user.forum_role==1}--> checked="checked" <!--{/if}-->>超级管理员<br>
								<input type="radio" value="2" name="data[User][forum_role]" onclick="changeForumRole(true)" <!--{if $user.forum_role==2}--> checked="checked" <!--{/if}-->>管理员<br>
								<input type="radio" value="3" name="data[User][forum_role]" onclick="changeForumRole(true)" <!--{if $user.forum_role==3}--> checked="checked" <!--{/if}-->>版主<br>
							</td>
							<td colspan="2">
								<input type="checkbox" id="boardsAll" onClick="chooseAllForumChannel(this)">全选<br>
								<!--{foreach from=$forumChannelList item=item}-->
									<input type="checkbox" name="channelIds[]" value="<!--{$item.channel_id}-->" <!--{if $item.user_forum_channel_id!=null}--> checked="checked" <!--{/if}-->>(ID:<!--{$item.channel_id}-->)<!--{$item.channel_text}--></b><br>
								<!--{/foreach}-->
							</td>
						</tr>
						<tr>
							<td></td>
							<td colspan="2"><button type="submit" class="butsubmit">提交</button>&nbsp;&nbsp;<button type="button" class="but2font" onclick="window.location.href='index.php?<!--{$returnParams}-->'">返回</button></td>
						</tr>
					</table>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
function selectSubmenu(obj){
	if ($(obj).attr("checked") == true) {
		$("input[name=menu[]]").each(function(){
			if ($(this).attr("parent_id") == $(obj).val()) {
				$(this).attr("checked", true);
			}
		});
	} else {
		$("input[name=menu[]]").each(function(){
			if ($(this).attr("parent_id") == $(obj).val()) {
				$(this).attr("checked", false);
			}
		});
	}
}

function selectParentMenu(obj){
	var pid = $(obj).attr("parent_id");
	if ($(obj).attr("checked") == true) {
		$("#menu"+pid).attr("checked", true);
	} else {
		var flag = false;
		$("input[name=menu[]]").each(function(){
			if ($(this).attr("parent_id") == pid && $(this).attr("checked") == true) {
				flag = true;
			}
		});
		$("#menu"+pid).attr("checked", flag);
	}
}

function chooseAllForumChannel(obj){
	var checked = $(obj).attr('checked');
	if(checked==false){
		$('input[name="channelIds[]"]').each(function(index,element){
			$(element).attr('checked',false);
		});
	}else{
		$('input[name="channelIds[]"]').each(function(index,element){
			$(element).attr('checked',true);
		});
	}
}
	
function boxselect(obj){
	var rankcode = $(obj).attr('rankcode');
	var checked = $(obj).attr('checked');
	if(checked==false){
		$('input[type=checkbox]').each(function(index,element){
			if($(element).attr('rankcode').indexOf(rankcode)==0&&$(element).attr('disabled')==false){
				$(element).attr('checked',false);
			}
		});
	}else{
		$('input[type=checkbox]').each(function(index,element){
			if($(element).attr('rankcode').indexOf(rankcode)==0&&$(element).attr('disabled')==false){
				$(element).attr('checked',true);
			}else if(rankcode.indexOf($(element).attr('rankcode'))==0&&$(element).attr('disabled')==false){
				$(element).attr('checked',true);
			}
		});
	}
}

function changeCmsRole(checked){
	if (checked == false) {
		$("#cms_role").attr("checked", false);
		$("input[name=menu[]]").each(function(){	
			$(this).attr("checked", false);
			$(this).attr("disabled", true);
		});
	} else {
		$("input[name=menu[]]").each(function(){
			var forumRoleFlag = 0;
			$("input[name=data[User][forum_role]]").each(function(){
				if ($(this).attr("checked") == true) {
					forumRoleFlag = 1;
					return false;
				}
			});
			if (forumRoleFlag == 1 || $(this).attr("forum_menu_flag") != 1) {
				$(this).attr("disabled", false);
			}
		});
	}
}

function changeForumRole(checked){
	if(checked==false){
		$('input[name="data[User][forum_role]"]').each(function(index,element){
			$(element).attr('checked',false);
		});
		$('input[name="menus[]"]').each(function(index,element){
			if($(element).attr('forum_menu_flag')==1){
				$(element).attr('checked',false);
				$(element).attr('disabled',true);
			}
		});
		$('#boardsAll').attr('disabled',true);
		$('#boardsAll').attr('checked',false);
		$('input[name="channelIds[]"]').attr('checked',false);
		$('input[name="channelIds[]"]').attr('disabled',true);
	}else if(checked==true){
		var forumRole=0;
		$('input[name="data[User][forum_role]"]').each(function(index,element){
			if($(element).attr('checked')==true){		
				forumRole = $(element).val();
				return false;
			}
		});
		if(forumRole==1){
			$('#boardsAll').attr('checked',true);
			$('#boardsAll').attr('disabled',true);
			$('input[name="channelIds[]"]').attr('checked',true);
			$('input[name="channelIds[]"]').attr('disabled',true);
		}else{
			$('#boardsAll').attr('disabled',false);
			$('input[name="channelIds[]"]').attr('disabled',false);
		}
		$('input[name="menus[]"]').each(function(index,element){
			if($(element).attr('forum_menu_flag')==1&&$('#cms_role').attr('checked')==true){
				$(element).attr('disabled',false);
			}
		});
	}
}

$().ready(function(){
	changeCmsRole($("#cms_role").attr('checked'));
	var checked=false;
	$('input[name="data[User][forum_role]"]').each(function(index,element){
		if($(element).attr('checked')==true){		
			checked = true;
			return false;
		}
	});
	changeForumRole(checked);
});
</script>
</html>