<?
require_once('include/global.php');
require_once("include/mail_lib.php");
require_once('conf.inc.php');


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


// data
	// get
		$sql = "
			SELECT
				mb_id, mb_name, mb_is_system, mb_saveday, mb_sort, mb_parent, html_limit
			FROM
				".$TB['MAIL_BOX']."
			WHERE
				m_no='". $AUTH['auth_m_no'] . "'
				AND mb_id='". $_GET['mb_parent'] . "'
			";
		$mb = db_get_row($sql);

		if ($mb === false) {
			msg('편지함이 존재하지 않습니다.');
		}

		// view
		$mb_view = array();
		$mb_view['mb_parent_name'] = $mb['mb_name'];

		// [2006-03-06] 보관기간
		$q = "SELECT d_saveday FROM ".$TB['DOMAIN']." WHERE d_no='".$AUTH['auth_d_no']."'";
		$d_saveday = db_get_one($q);
		if ($d_saveday > 0)
		{
			foreach ($G_SYS['MB_SAVEDAY'] as $key=>$val)
			{
				if ($key > $d_saveday)
					break;
				if ($key != 0)
					$mb_saveday_ar[$key] = $val;
			}	// foreach()
		} else
		{
			$mb_saveday_ar = $G_SYS['MB_SAVEDAY'];
		}	// if()
		$mb_view['mb_saveday'] = select_list_value($mb['mb_saveday'], array_values($mb_saveday_ar), array_keys($mb_saveday_ar), NULL, 0, 1);


		// 상위 편지함 가져오기
		if ($_GET['mb_parent']) {
			$mb['mb_parent'] = $_GET['mb_parent'];
		}

		// [2023-04-27] 편지함 트리 지원
		$cg                = get_mail_box_tree_class();
		$cg_dataall        = $cg->getRowsByParent(0, 255, 1, "AND " . get_mail_box_where());
		$cg_dataall_option = $cg->getSelectOption($cg_dataall, $_GET['adg_no']);
		$mb_parent        = select_list_value(
			$mb['mb_parent'], $cg_dataall_option['val'], $cg_dataall_option['key'], null, 0, 1
		);


// set
	$CFG['TITLE'] = '<b>환경설정</b> >> <b>편지함관리</b> >> <b>하위 편지함 생성</b>';


// skin view
	$layout = ($_GET['is_window_close']) ? 'window_open' : 'self';
	nskinset('webmail', 'mail_box_add.html', $layout);
	include($NSKIN['view_layout']);


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