<?php
header("Content-type:text/html;charset=utf-8");  
session_start();
$session_admin = isset($_SESSION['admin']) ? $_SESSION['admin'] : ''; 
if ($session_admin == '') {
	die("Can not access");
}
require_once("../common.php");
checkadminrights($session_admin, 'groups');

function step2() {
	require_once("../common.php");

	$groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
	$groupname = isset($_GET['groupname']) ? urldecode($_GET['groupname']) : '';
	$ownerusertype = isset($_GET['ownerusertype']) ? $_GET['ownerusertype'] : '';
	$searchtype = isset($_GET['searchtype']) ? $_GET['searchtype'] : '';
	$searchparam = isset($_GET['searchparam']) ? urldecode($_GET['searchparam']) : '';
	$pageindex = isset($_GET['pageindex']) ? $_GET['pageindex'] : '';

	//subpageurlparams
	$subpageurlparams = 'ownerusertype=' . $ownerusertype . 
		'&searchtype=' . $searchtype . 
		'&searchparam=' . urlencode($searchparam) . 
		'&pageindex=' . $pageindex;

	$methodname = 'Admin.RemoveGroup';
	$requestinfo = '<?xml version="1.0" encoding="utf-8"?><request>' . 
		'<ip>' . getip() . '</ip>' . 
		'<groupid>' . $groupid . '</groupid>' . 
		'</request> ';
	$responseinfo = '';
	$responsexml = null;
	$errorcode = ERRORCODE_UNKNOWN;

	$cmd = new COM("OpenCom.Command");
	$methodname = iconv('UTF-8', 'GBK//IGNORE', $methodname);
	$requestinfo = iconv('UTF-8', 'GBK//IGNORE', $requestinfo);
	if ($cmd->Execute($methodname, $requestinfo, $responseinfo, 5000)) {
		$responseinfo = iconv('GBK', 'UTF-8//IGNORE', $responseinfo);
		$responsexml = simplexml_load_string($responseinfo);
		$errorcode = $responsexml->errorcode;
	}
	$cmd = null;

	switch($errorcode) {
		case ERRORCODE_OK: 
			header("location: groups.php?{$subpageurlparams}");
			break;
		default:
			header("location: groups.php?{$subpageurlparams}");
	}//switch
}//step2

$step = isset($_GET['step']) ? $_GET['step'] : '1'; 

if ($step == '2') {
	step2();
	exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="../css/base.css" />
</head>
<body>

<?php
require_once("../common.php");

$groupid = isset($_GET['groupid']) ? $_GET['groupid'] : '';
$groupname = isset($_GET['groupname']) ? urldecode($_GET['groupname']) : '';
$ownerusertype = isset($_GET['ownerusertype']) ? $_GET['ownerusertype'] : '';
$searchtype = isset($_GET['searchtype']) ? $_GET['searchtype'] : '';
$searchparam = isset($_GET['searchparam']) ? urldecode($_GET['searchparam']) : '';
$pageindex = isset($_GET['pageindex']) ? $_GET['pageindex'] : '';

//subpageurlparams
$subpageurlparams = 'ownerusertype=' . $ownerusertype . 
	'&searchtype=' . $searchtype . 
	'&searchparam=' . urlencode($searchparam) . 
	'&pageindex=' . $pageindex;

//subpageurlparams2
$subpageurlparams2 = $subpageurlparams . '&groupid=' . $groupid . '&groupname=' . urlencode($groupname);

$selected1 = '';
$selected2 = '';
$selected3 = '';

if ($ownerusertype == '-1') {
	$selected1 = ' class="selected"';
} else if ($ownerusertype == '1') {
	$selected2 = ' class="selected"';
} else if ($ownerusertype == '0') {
	$selected3 = ' class="selected"';
}

echo<<<EOT
		<div class="msgbox">
			<div class="msgbox_text">
				<img width="40px" height="40px" align="absmiddle" src="../images/warning.gif" />&nbsp;确定要删除&nbsp;&quot;$groupname&quot;&nbsp;群组吗？
			</div>
			<div class="msgbox_btns">
				<input class="cssbtn" type="button" value="确定" onclick="window.location='groups_remove.php?step=2&{$subpageurlparams2}'" />
				<input class="cssbtn" type="button" value="取消" onclick="window.location='groups.php?{$subpageurlparams}'" />
			</div>
		</div>
EOT;
?>

</body>
</html>
