<?php
define('EmpireCMSAdmin','1');
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$editor=1;
//驗證用戶
$lur=is_login();
$logininid=$lur['userid'];
$loginin=$lur['username'];
$loginrnd=$lur['rnd'];
$loginlevel=$lur['groupid'];
$loginadminstyleid=$lur['adminstyleid'];
//ehash
$ecms_hashur=hReturnEcmsHashStrAll();
//驗證權限
CheckLevel($logininid,$loginin,$classid,"viewgroup");
$enews=ehtmlspecialchars($_GET['enews']);
$postword='增加';
$vgid=0;
$r=array();
$url="<a href='ListViewGroup.php".$ecms_hashur['whehref']."'>管理會員訪問組</a>&nbsp;->&nbsp;增加會員訪問組";
if($enews=="EditViewGroup")
{
	$vgid=(int)$_GET['vgid'];
	$postword='修改';
	$r=$empire->fetch1("select * from {$dbtbpre}enewsvg where vgid='$vgid'");
	$url="<a href='ListViewGroup.php".$ecms_hashur['whehref']."'>管理會員訪問組</a>&nbsp;->&nbsp;修改會員訪問組：<b>".$r[gname]."</b>";
}
//會員組
$i=0;
$membergroup='';
$mgsql=$empire->query("select groupid,groupname from {$dbtbpre}enewsmembergroup order by level");
while($level_r=$empire->fetch($mgsql))
{
	$i++;
	$br='';
	if($i%6==0)
	{
		$br='<br>';
	}
	if(strstr($r['gids'],','.$level_r['groupid'].','))
	{$checked=" checked";}
	else
	{$checked="";}
	$membergroup.="<input type='checkbox' name='membergroup[]' value='$level_r[groupid]'".$checked.">".$level_r[groupname]."&nbsp;".$br;
}
//內部組
$i=0;
$ingroup='';
$minsql=$empire->query("select gid,gname from {$dbtbpre}enewsingroup order by myorder");
while($min_r=$empire->fetch($minsql))
{
	$i++;
	$br='';
	if($i%6==0)
	{
		$br='<br>';
	}
	if(strstr($r['ingids'],','.$min_r['gid'].','))
	{$checked=" checked";}
	else
	{$checked="";}
	$ingroup.="<input type='checkbox' name='ingroup[]' value='$min_r[gid]'".$checked.">".$min_r[gname]."&nbsp;".$br;
}
//管理組
$i=0;
$madmingroup='';
$agsql=$empire->query("select agid,agname from {$dbtbpre}enewsag order by isadmin");
while($ag_r=$empire->fetch($agsql))
{
	$i++;
	$br='';
	if($i%6==0)
	{
		$br='<br>';
	}
	if(strstr($r['agids'],','.$ag_r['agid'].','))
	{$checked=" checked";}
	else
	{$checked="";}
	$madmingroup.="<input type='checkbox' name='madmingroup[]' value='$ag_r[agid]'".$checked.">".$ag_r[agname]."&nbsp;".$br;
}
db_close();
$empire=null;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>會員訪問組</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
  <tr>
    <td height="25">位置：<?=$url?></td>
  </tr>
</table>
<form name="form1" method="post" action="ListViewGroup.php">
  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
  <?=$ecms_hashur['form']?>
    <tr class="header"> 
      <td width="20%" height="25"><?=$postword?>會員訪問組</td>
      <td width="80%" height="25"><input name="enews" type="hidden" id="enews" value="<?=$enews?>"> 
        <input name="vgid" type="hidden" id="vgid" value="<?=$vgid?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">組名稱</td>
      <td height="25"> <input name="gname" type="text" id="gname" value="<?=$r[gname]?>" size="30">      </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">允許會員組</td>
      <td height="25"><?=$membergroup?></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">允許會員內部組</td>
      <td height="25"><?=$ingroup?></td>
    </tr>
    <tr bgcolor="#FFFFFF">
      <td height="25">允許會員管理組</td>
      <td height="25"><?=$madmingroup?></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"> <input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
