<?
require_once('include/global.php');
require_once('include/member_group_lib.php');
auth_limit("admin");


// check
	if (!$_POST['chk_m_no'])
		msg('올바른 URL로 접근하여 주십시오');

// [2006-03-11] 메일서버가 동작중인지 확인
	require_once('include/admin_lib.php');
	mail_server_check_limit();		

// data
	for ($i=0; $i<sizeof($_POST['chk_m_no']); $i++)
	{
		// [2013-02-07] 메일용량 할당량, 메일계정 할당수 제한		
		$sql = "SELECT d.d_name, m.m_quota, m.m_bigfile_quota, m.m_webhard_quota FROM " . $TB['MEMBER'] . " m, " . $TB['DOMAIN'] . " d WHERE m.m_no='" . $_POST['chk_m_no'][$i] . "' AND m.d_no=d.d_no";
		$mbr = db_get_row($sql);
		$G_SYS['MAIL_DOMAIN'] = $mbr['d_name'];
		mbr_add_limit($mbr['m_quota'], $mbr['m_bigfile_quota'], $mbr['m_webhard_quota']);

		$q_where = '';
		if ($AUTH['auth_m_level'] < $G['LEVEL']['serveradmin'])
		{
			$q_where = " AND d_no='" . $AUTH['auth_d_no'] . "' ";
		}	// if()

		/*
		if ($_POST['sel_mbr_group'])
		{
			// [2006-02-21] 회원그룹
			$q = "SELECT mg_quota_default FROM ".$TB['MEMBER_GROUP']." WHERE mg_no='".$_POST['sel_mbr_group']."'".$q_where;
			$m_quota = db_get_one($q);
			if ($m_quota === NULL)
				msg("존재하지 않는 회원그룹입니다.");

			$sql = "
				UPDATE
					" . $TB['MEMBER'] . "
				SET
					m_level='" . $G[LEVEL][user] . "',
					mg_no='" . $_POST['sel_mbr_group'] . "',
					m_quota='" . $m_quota . "'
				WHERE
					m_no='" . $_POST['chk_m_no'][$i] . "'
					AND m_level='" . $G[LEVEL][wait] . "'
					$q_where				
				";
			db_query($sql);

			// 웹메일용 처리
			$m_id = db_get_one("SELECT m_id FROM " . $TB['MEMBER'] . " WHERE m_no = '" . $_POST['chk_m_no'][$i] . "'".$q_where);
			mbr_quota_mod($m_id, $m_quota);
		} else 
		{
		*/

			// [2009-06-02] 조직 갱신
			$q_mg_no = '';
			if ($_POST['sel_mbr_group'])
			{
				$mg_no_default = member_group_rel_update($_POST['chk_m_no'][$i], $_POST['sel_mbr_group'], $isReset=true);
				if ($mg_no_default > 0)
					$q_mg_no = " mg_no = '".$mg_no_default."', ";
			}	// if()


			$sql = "
				UPDATE
					" . $TB['MEMBER'] . "
				SET
					".$q_mg_no."
					m_level='" . $G[LEVEL][user] . "'
				WHERE
					m_no='" . $_POST['chk_m_no'][$i] . "'
					AND m_level='" . $G[LEVEL][wait] . "'
					$q_where				
				";
			db_query($sql);
		//}	// if()

		// [2006-08-08] 사용자 상태 갱신
		mbr_stats_update($_POST['chk_m_no'][$i]);
	}	// for()


// end
	#msg("수정되었습니다.", 0);
	movepage($back_url);


require_once('include/global_end.php');
?>