<?php
# Subroutine: adm_permission_add.php called by Admin.php
# Xinfeng Chen, 2002.11.20
# Input: $bid, $user
# Output: $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_user.php');

$oUsr=new CUser;
$oPrm=new CPermission;

if(!$bid){
 $errmsg="指定论坛(ID=$bid)不存在！";
}elseif($oUsr->load($user)){
 $oPrm->load($bid);
 $oPrm->appendNew(); $oPrm->user=$oUsr->name; $oPrm->update();
 if(!$oPrm->store($bid)){$errmsg='存储权限文件发生错误！';}
 else{$errmsg="User $user is added(BID=$bid).";}
}else{
 $errmsg="用户[$user]未找到！";
}

#--- Jump to permission page ---
$f_bid=$bid;
include('admin/adm_permission_1.php');

exit;

?>