<?php
# Subroutine: adm_permission_1.php called by Admin.php
# Xinfeng Chen, 2002.11.20
# Input: $f_bid, $errmsg

require_once('bin/config.php');
require_once('admin/adm.inc');

#--- Validate dministrator ---
include('admin/adm_validate.php');
if(!$adm_validated){jumpTo('admin.php?cmd=logon'); exit;}

#--- Start Processing ---
require_once('core/class_forum_base.php');
CForumBase::setFileBase("$filepath");
require_once('core/base_array_file.php');
require_once('core/class_permission.php');
require_once('core/base_memo_file.php');
require_once('core/class_board.php');

#--- Prepare board info ---
$oBrd=new CBoard;
if(!$oBrd->load($f_bid)){
 $errmsg='board not foud';
 include('admin/adm_permission.php');
 exit;
}

page_header();

print <<<EOT
<h1>权限管理</h1>
<p>添加/删除允许进入指定加密论坛的拥护。</p>
EOT;

#--- Process error message from previous page ---
if($errmsg){
 print <<<EOT
<table border=1 width=100% cellpadding=6 align=center>
<tr><td width=100% align=center>
<b><font color=FF6633>$errmsg</font></b>
</td></tr></table>
EOT;
}

#--- Prepare board info ---
print <<<EOT
<form name="form1" method="post" action="?cmd=permission_add&bid=$f_bid">
<table width=100% cellpadding=4 cellspacing=1 border=0 class="forumline">
<tr> 
 <th class="thHead" colspan="3"><b>增加/删除用户</b></th>
</tr>
<tr> 
 <td class="row2">论坛信息</td>
 <td class="row2"><b>$oBrd->name</b><br>$oBrd->desc</td>
 <td class="row2"><a href="?cmd=permission">选择其它论坛</a></td>
</tr>
EOT;

#--- Print granted user info ---
$oPrm=new CPermission;
$oPrm->load($f_bid);
$usize=$oPrm->itemCount();

if($usize>0){
 print <<<EOT
<tr> 
 <td class="row1" rowspan="$usize">已授权用户</td>
 <td class="row1">$oPrm->user</td>
 <td class="row1">
 <a href="?cmd=permission_remove&bid=$f_bid&user={$oPrm->user}">删除</a>
 </td>
</tr>
EOT;
}else{
 print <<<EOT
<tr> 
 <td class="row1">已授权用户</td>
 <td class="row1">[无]</td>
 <td class="row1">---</td>
</tr>
EOT;
}

for($i=1;$i<$usize;$i++){
 $oPrm->moveTo($i);
 print <<<EOT
<tr> 
 <td class="row1">$oPrm->user</td>
 <td class="row1">
 <a href="?cmd=permission_remove&bid=$f_bid&user={$oPrm->user}">删除</a>
 </td>
</tr>
EOT;
}

#--- Print add-user form ---
print <<<EOT
<tr> 
 <td class="row3">添加用户</td>
 <td class="row3"> 用户名: 
  <input type="text" name="user">
 </td>
 <td class="row3"> 
  <input type="submit" name="Submit2" value="确定">
 </td>
</tr>
</table>
</form>
EOT;

page_footer();
exit;

?>