<?php
$sub_menu = "777400";
include_once('./_common.php');

include_once(AMINA_PATH.'/lib/admin.lib.php');

$g5['title'] = $g4['title'] = '여분필드관리';

include_once(G5_ADMIN_PATH.'/admin.head.php');

if(AMINA) echo '<br /><br />'."\n";

?>

<link rel="stylesheet" href="<?php echo AMINA_URL; ?>/css/admin.css" />
<script>
	var amina_url = "<?php echo AMINA_URL; ?>";
	var gnu_url = "<?php echo AMINA_URL; ?>";
	var bo_table  = "<?php echo $bo_table; ?>";
</script>
<script src="<?php echo AMINA_URL; ?>/js/admin.js"></script>

<div style="padding:10px; background:#333; color:#fff;">
	<b>※ 여분필드관리</b>
</div>
<div style="border:1px solid #ddd; line-height:20px; background#fafafa;">
	<ol>
	<li>그누보드 기본(cf_)/그룹(gr_)/게시판(bo_) 여분필드 설정입니다.</li>
	<li>일반페이지에 대한 타이틀 및 설명 설정은 amina.skin.php 파일에서 직접 해주셔야 합니다.</li>
	<li>인기검색어는 테마에 따라 적용안 될 수 있으며, 각 검색어는 콤마(,)로 구분해서 입력해 주세요.</li>
	<li>amina.skin.php 파일의 기본 설정테마와 별도의 테마와 컬러셋을 그룹에 적용할 수 있습니다.</li>
	<li>별도 적용할 테마와 컬러셋을 각각 "PC|모바일" 형식으로 바(|)를 이용하여 구분해서 등록해 주세요. ex) basic-amina|basic</li>
	<li>최고/그룹/보드 복수관리자, 관리자 제외 표시, 특별회원, 글등록회원은 회원아이디를 콤마(,)로 구분해서 입력해 주세요.</li>
	<li>복수관리자 설정을 위해서는 그누보드 원본수정이 필요하며, 수정방법은 매뉴얼을 참고해 주세요.</li>
	</ol>
</div>
<form id="amina_setup" name="fboardform" method="post" action="#" onsubmit="return fboardform_submit(this);">
<input type="hidden" name="mode" value="cf">

<table border=0 class="admin_tbl">
<tr class="head_gray">
<td style="width:20px;" align="center">
	<input type="checkbox" class="all_chk">
</td>
<td align="center">구분</td>
<td>아이디</td>
<td align="center" width="80">항목</td>
<td>여분필드 입력하기</td>
</tr>

<tr>
<td align="center" rowspan="4"><input type="checkbox" name="m_chk[]" value="0"></td>
<td align="center" rowspan="4"><b>기본</b></td>
<td rowspan="4">
	<input type="hidden" name="m_type[]" value="cf">
	<input type="hidden" name="m_id[]" value="1">
	<input type="hidden" name="m_title[]" value="1">
	<input type="hidden" name="m_desc[]" value="1">
	<input type="hidden" name="m_at[]" value="1">
	<input type="hidden" name="m_ac[]" value="1">
	<b>-</b>
</td>
<td align="center" bgcolor="#fafafa"><b>인기검색어</b></td>
<td>
	<input type="text" name="m_popular[]" size="76" value="<?php echo $config['cf_3'];?>">
</td>
</tr>
<tr>
<td align="center" bgcolor="#fafafa">최고관리자</td>
<td>
	<input type="text" name="m_admin[]" size="76" value="<?php echo $config['cf_1'];?>">
</td>
<tr>
<td align="center" bgcolor="#fafafa">관리자제외</td>
<td>
	<input type="text" name="m_admin_display[]" size="76" value="<?php echo $config['cf_1_subj'];?>">
</td>
</tr>
<tr>
<td align="center" bgcolor="#fafafa">스페셜회원</td>
<td>
	<input type="text" name="m_writer[]" size="76" value="<?php echo $config['cf_2'];?>">
</td>
</tr>
<?php
	if(AMINA) {
		$gr_order = 'gr_order';
		$bo_order = 'bo_order';
	} else {
		$gr_order = 'gr_10';
		$bo_order = 'bo_order_search';
	}

	$z = 1;
	$sql = " select * from {$g5['group_table']} order by $gr_order ";
	$result = sql_query($sql);
	for ($i=0; $row=sql_fetch_array($result); $i++) {
?>
	<tr bgcolor="#f5f5f5">
	<td align="center" rowspan="3"><input type="checkbox" name="m_chk[]" value="<?php echo $z;?>"></td>
	<td align="center" rowspan="3"><b>그룹</b></td>
	<td rowspan="3">
		<input type="hidden" name="m_type[]" value="gr">
		<input type="hidden" name="m_id[]" value="<?php echo $row['gr_id'];?>">
		<input type="hidden" name="m_popular[]" value="1">
		<input type="hidden" name="m_admin_display[]" value="1">
		<input type="hidden" name="m_writer[]" value="1">
		<b><?php echo $row['gr_id'];?></b>
	</td>
	<td align="center"><b>타이틀표시</b></td>
	<td>
		<input type="text" name="m_title[]" size="26" value="<?php echo $row['gr_1_subj'];?>">
		설명글 <input type="text" name="m_desc[]" size="36" value="<?php echo $row['gr_1'];?>">
	</td>
	</tr>
	<tr bgcolor="#f5f5f5">
	<td align="center">적용할테마</td>
	<td>
		<input type="text" name="m_at[]" size="26" value="<?php echo $row['gr_3_subj'];?>">
		컬러셋 <input type="text" name="m_ac[]" size="36" value="<?php echo $row['gr_4_subj'];?>">
	</td>
	</tr>
	<tr bgcolor="#f5f5f5">
	<td align="center">그룹관리자</td>
	<td>
		<input type="text" name="m_admin[]" size="76" value="<?php echo $row['gr_3'];?>">
	</td>
	</tr>
	<?php
		$sql2 = " select * from {$g5['board_table']} where gr_id = '{$row['gr_id']}' order by $bo_order ";
		$result2 = sql_query($sql2);
		$ressult2_cnt = mysql_num_rows($result2);
		for ($k=0; $row2=sql_fetch_array($result2); $k++) {
			$z++;
	?>
		<tr>
		<td align="center" rowspan="3"><input type="checkbox" name="m_chk[]" value="<?php echo $z;?>"></td>
		<td align="center" rowspan="3">보드</td>
		<td rowspan="3">
			<input type="hidden" name="m_type[]" value="bo">
			<input type="hidden" name="m_id[]" value="<?php echo $row2['bo_table'];?>">
			<input type="hidden" name="m_popular[]" value="1">
			<input type="hidden" name="m_admin_display[]" value="1">
			<input type="hidden" name="m_at[]" value="1">
			<input type="hidden" name="m_ac[]" value="1">
			<b><a href="<?php echo G5_BBS_URL;?>/board.php?bo_table=<?php echo $row2['bo_table'];?>"><?php echo $row2['bo_table'];?></a></b>
		</td>
		<td align="center" bgcolor="#fafafa"><b>타이틀표시</b></td>
		<td>
			<input type="text" name="m_title[]" size="26" value="<?php echo $row2['bo_1_subj'];?>">
			설명글 <input type="text" name="m_desc[]" size="36" value="<?php echo $row2['bo_1'];?>">
		</td>
		</tr>
		<tr>
		<td align="center" bgcolor="#fafafa">보드관리자</td>
		<td>
			<input type="text" name="m_admin[]" size="76" value="<?php echo $row2['bo_3'];?>">
		</td>
		</tr>
		<tr>
		<td align="center" bgcolor="#fafafa">글등록회원</td>
		<td>
			<input type="text" name="m_writer[]" size="76" value="<?php echo $row2['bo_4'];?>">
		</td>
		</tr>
	<?php } ?>
<?php $z++; } ?>
</table>
<br>
<p align="center"><input type="submit" accesskey="s" value=" 저장하기 " class="btn_red"> <label><input type="checkbox" class="all_chk"> 전체선택</label></p>
</form>

<script>
	$(function(){
		$('.all_chk').click(function(){
			$('[name="m_chk[]"]').attr('checked', this.checked);
		});
	});

	function fboardform_submit(f) {
		var cnt = 0;
		for (var i=0; i<f.length; i++) {
			if (f.elements[i].name == "m_chk[]" && f.elements[i].checked)
			cnt++;
		}

		if (!cnt) {
			alert("저장할 설정을 하나 이상 선택하세요.");
			return false;
		}

		f.action = "<?php echo AMINA_URL; ?>/admin.extra.update.php";

		return true;
	}
</script>

<?php include_once (G5_ADMIN_PATH.'/admin.tail.php'); ?>