<?php
//引入语言包
	$g_langpackage=new grouplp;

//变量区
	$user_id=get_sess_userid();
	$group_id=short_check(get_argg('group_id'));
	$userid=short_check(get_argg('userid'));
	
//数据表定义
	$t_users=$tablePreStr."users";
	$t_groups=$tablePreStr."groups";
  $t_group_members=$tablePreStr."group_members";
  
//定义读操作
	dbtarget('r',$dbServs);	
	$dbo=new dbex();
	
//引入公共函数
	require("foundation/module_group.php");

//权限判断
	$role=pri_limit($dbo,$user_id,$group_id);

	if($role>=1){
		action_return(0,$g_langpackage->g_no_privilege,"-1");
	}

	$sql="select group_manager_name,group_manager_id from $t_groups where group_id=$group_id";
	$group_row=$dbo->getRow($sql);
	$group_manager=$group_row['group_manager_name'];
	$group_manager_id=$group_row['group_manager_id'];

  $sql="select user_name from $t_users where user_id=$userid";
  $user_row=$dbo->getRow($sql);
	$username=$user_row['user_name'];

//所撤销的管理员不存在
	if(!preg_match("/,$userid,/",$group_manager_id)){
		action_return(0,$g_langpackage->g_no_manager,"-1");
		}

	$group_manager=preg_replace("/\|$username\|/","|",$group_manager);
	$group_manager_id=preg_replace("/,$userid,/",",",$group_manager_id);
	
//定义写操作
	dbtarget('w',$dbServs);	
	
  $sql="update $t_groups set group_manager_name='$group_manager',group_manager_id='$group_manager_id' where group_id=$group_id";
  $dbo->exeUpdate($sql);
   
  $sql="update $t_group_members set role=2 where user_id=$userid&&group_id=$group_id";
  $dbo->exeUpdate($sql);
	
	$jump="modules.php?app=group_member_manager&group_id=$group_id";
	action_return(1,'',$jump);

?>

