<?php include 'header.tpl.php';?>
<style>
.metit{float:left;width:99%;text-align:left}
.meadminpage{float:left;width:80%;text-align:left;padding-left:20px}
.meadminpageact{float:left;padding-left:35px;text-align:left;width:80%}
</style>
<div class="pMenu">
<li><a href="javascript:frmExecute('');">管理</a></li>
<?php if($obj_ctl_limit->chk_act("add")){?><li><a href="javascript:frmExecute('add');">添加</a></li><?php }?>
<?php if($obj_ctl_limit->chk_act("edit")){?><li class="sel"><a href="javascript:frmExecute('edit');">编辑</a></li><?php }?>
<li class="info"><a href="javascript:inc_show_help(195);" style="color:#ff0000">帮助</a></li>
</div>
<div style="width:100%">
<table class='pEditTable'>
<tr class='pTabTitRow'>
	<td class='pTabTitCol' colspan="2"></td></tr>
<tr><td class="pTabColName">组　名：</td><td class="pTabColVal"><input type="input" name="group_name" value="<?php echo $arr_group["group_name"];?>"></td>
	</tr>
<tr><td class="pTabColName">向下继承：</td><td class="pTabColVal"><input type="checkbox" name="group_inherit_down" value="1" <?php if($arr_group["group_inherit_down"]==1) echo "checked";?>></td>
	</tr>
<tr><td class="pTabColName">系统权限：</td><td class="pTabColVal">
	<?php foreach($arr_model as $item){?>
		<div class="metit">
			<input type="hidden" name="model_regkey_<?php echo $item["model_id"];?>" value="<?php echo $item["model_regkey"];?>">
			<?php if(in_array($item["model_id"],$arr_parent_model_ids)){?>
				<input type="checkbox" name="x_<?php echo $item["model_id"];?>" value="" checked disabled>
				<input type="checkbox" name="model_id[]" value="<?php echo $item["model_id"];?>" onclick="me_adminpage_click(this.checked,'id_<?php echo $item["model_id"]?>');" style="display:none" checked>
			<?php }else{ ?>
			<input type="checkbox" name="model_id[]" value="<?php echo $item["model_id"];?>" onclick="me_adminpage_click(this.checked,'id_<?php echo $item["model_id"]?>');" <?php if(in_array($item["model_id"],$arr_group["group_model_ids"])||in_array($item["model_id"],$arr_parent_model_ids)) echo "checked";?>>
			<?php }?>
			<?php echo $item["model_name"];?>
		</div>
		<div class="megroup" id="id_<?php echo $item["model_id"]?>" style="display: <?php if(!(in_array($item["model_id"],$arr_group["group_model_ids"])||in_array($item["model_id"],$arr_parent_model_ids))) echo "none";?>">
			<?php foreach($item["page"] as $item_next){?>
				<div class="meadminpage">
				<input type="hidden" name="page_url_<?php echo $item_next["page_id"]?>" value="<?php echo $item_next["page_url"]?>">
				 <?php if((isset($arr_parent_model_page[$item["model_regkey"]])&&in_array($item_next["page_url"],$arr_parent_model_page[$item["model_regkey"]]))){?>
					<input type="checkbox" name="xx_<?php echo $item["model_id"];?>" value="" checked disabled>
					<input type="checkbox" name="page_<?php echo $item["model_id"];?>[]" value="<?php echo $item_next["page_id"]?>" onclick="me_adminpage_click(this.checked,'obj_<?php echo $item_next["page_id"]?>');" style="display:none">
				 <?php }else{ ?>
				<input type="checkbox" name="page_<?php echo $item["model_id"];?>[]" value="<?php echo $item_next["page_id"]?>" onclick="me_adminpage_click(this.checked,'obj_<?php echo $item_next["page_id"]?>');" <?php if(in_array($item_next["page_url"],$arr_model_page[$item["model_regkey"]])) echo "checked";?>>
				<?php }?>
				<?php echo $item_next["page_url"]?>　［<?php echo $item_next["page_name"]?>］</div>
				<div class="meadminpageact" id="obj_<?php echo $item_next["page_id"]?>" style="display: <?php if(!(in_array($item_next["page_url"],$arr_model_page[$item["model_regkey"]])||(isset($arr_parent_model_page[$item["model_regkey"]])&&in_array($item_next["page_url"],$arr_parent_model_page[$item["model_regkey"]])))) echo "none";?>"><input type="checkbox" name="page_act_<?php echo $item_next["page_id"]?>[]" value="" disabled checked>查看
				<?php foreach($item_next["page_act"] as $act=>$key){?>
					<input type="checkbox" name="page_act_<?php echo $item_next["page_id"]?>[]" value="<?php echo $act?>" <?php if(in_array($act,$arr_model_page_act[$item["model_regkey"]][$item_next["page_url"]])||(isset($arr_parent_model_page_act[$item["model_regkey"]][$item_next["page_url"]]) && in_array($act,$arr_parent_model_page_act[$item["model_regkey"]][$item_next["page_url"]]))) echo "checked"?> <?php if(isset($arr_parent_model_page_act[$item["model_regkey"]][$item_next["page_url"]]) &&in_array($act,$arr_parent_model_page_act[$item["model_regkey"]][$item_next["page_url"]])) echo "disabled";?>><?php echo $key?>
				<?php }?>
				</div>
			<?php }?>
		</div>
	<?php }?>
</td>
	</tr>
<tr><td class="pTabColName">文章权限：</td><td class="pTabColVal" id="id_channel">
	<?php foreach($arr_channel as $item){
			$str_checked="";
			if(in_array($item['channel_id'],$arr_group["group_article"]["channel"])) $str_checked=" checked";
			echo "<li><input type='checkbox'".$str_checked." name='channel_id[]' value='".$item['channel_id']."' onclick=\"me_channel(".$item['channel_id'].",this.checked);\">".$item["channel_name"]."</li>";
			echo $item["folder"];
	}?>
</td>
	</tr>
<tr><td colspan=2 class="pTabSubmit">
<?php if($obj_ctl_limit->chk_act("save")){?>
<input type="button" name="subok" value="保存" class="pSubmit" onclick="frmExecute('save')">
<?php }else{?>
<font color=red>您没有保存权限！</font>
<?php }?>
</td></tr>
</table>
</div>
<script>
function me_adminpage_click(msgx,msgy)
{
	obj=document.getElementById(msgy);
	if(msgx){
		obj.style.display="";
	}else{
		obj.style.display="none";
	}
}
function me_channel(msgid,msgchecked){
	var obj_channel=document.getElementById("id_channel");
	var obj_li=obj_channel.getElementsByTagName("input");
	var str_x,arr_x,str_display,str_y;
	var str_var="";
	str_y="c"+msgid;
	if(msgchecked){
		str_var="disabled";
	}
	for(var i=0;i<obj_li.length;i++){
		str_x=obj_li[i].id;
		if(str_x){
			arr_x=str_x.split("_");
			if(arr_x[1]==str_y){
				obj_li[i].disabled=str_var;
			}
		}
	}
}
function me_folder_check(msgchecked,msgid){
	var obj_channel=document.getElementById("id_channel");
	var obj_li=obj_channel.getElementsByTagName("input");
	var str_x,arr_x,str_display;
	var str_var="";
	if(msgchecked){
		str_var="disabled";
	}
	for(var i=0;i<obj_li.length;i++){
		str_x=obj_li[i].id;
		if(str_x){
			arr_x=str_x.split("_");
			for(var j=0;j<arr_x.length;j++){
				if(parseInt(arr_x[j])==parseInt(msgid) && parseInt(arr_x[arr_x.length-1])!=parseInt(msgid)){
					obj_li[i].disabled=str_var;
				}
			}
		}
	}
}
<?php foreach($arr_group["group_article"]["folder"] as $item){?>
me_folder_check(true,<?php echo $item;?>);
<?php }?>
<?php foreach($arr_group["group_article"]["channel"] as $item){?>
me_channel(<?php echo $item;?>,true);
<?php }?>
</script>

<?php include 'footer.tpl.php';?>