그누보드 [G5] 글목록에서 카테고리(분류) 일괄 변경하기
페이지 정보
본문
1-1. 그누보드5 / skin / board / 폴더 / list.skin.php
<li><input type="submit" name="btn_submit" value="선택이동" onclick="document.pressed=this.value"></li>
를 아래와 같이 내용 추가
<li><input type="submit" name="btn_submit" value="선택이동" onclick="document.pressed=this.value"></li>
<?php if ($is_category) { ?><li><input type="submit" name="btn_submit" value="분류이동" onclick="document.pressed=this.value"></li><?php } ?>
1-2. 그누보드5 / skin / board / 폴더 / list.skin.php
if(document.pressed == "선택이동") {
select_copy("move");
return;
}
를 아래와 같이 내용 추가
if(document.pressed == "선택이동") {
select_copy("move");
return;
}
if(document.pressed == "분류이동") {
select_cate();
return;
}
1-3. 그누보드5 / skin / board / 폴더 / list.skin.php 맨끝
</script>
<?php } ?>
를 아래와 같이 내용 추가
//선택한 게시물의 분류를 변경함
function select_cate() {
var f = document.fboardlist;
str = "분류이동";
var sub_win = window.open("", "cate", "left=50, top=50, width=500, height=550, scrollbars=1");
f.sw.value = "cate";
f.target = "cate";
f.action = "<?php echo $board_skin_url; ?>/category.php";
f.submit();
}
</script>
<?php } ?>
2. 그누보드5 / skin / board / 폴더 / _common.php 생성
<?php
include_once('../../../common.php');
// 테마 폴더 스킨폴더 이용할때 아래꺼 사용
//include_once('../../../../../common.php');
?>
3. 그누보드5 / skin / board / 폴더 / category.php 생성
<?php
include_once('./_common.php');
$act = "분류이동";
// 게시판 관리자 이상 복사, 이동 가능
if ($is_admin != 'board' && $is_admin != 'group' && $is_admin != 'super')
alert_close("게시판 관리자 이상 접근이 가능합니다.");
$g5['title'] = '게시물 ' . $act;
include_once(G5_PATH.'/head.sub.php');
$wr_id_list = '';
if ($wr_id)
$wr_id_list = $wr_id;
else {
$comma = '';
for ($i=0; $i<count($_POST['chk_wr_id']); $i++) {
$wr_id_list .= $comma . $_POST['chk_wr_id'][$i];
$comma = ',';
}
}
$catelist = $board['bo_category_list'];
$list = explode('|',$catelist);
?>
<style>
.tbl_frm_categotry_update {margin:0 0 20px}
.tbl_frm_categotry_update table {width:100%;border-collapse:collapse;border-spacing:0}
.tbl_frm_categotry_update th {padding:5px 3px;border:1px solid #e9e9e9;border-left:0;background:#f5f8f9;text-align:center}
.tbl_frm_categotry_update td {padding:5px 3px;border-top:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9;background:transparent}
.tbl_frm_categotry_update textarea, .frm_update_date_input {border:1px solid #e4eaec;background:#f7f7f7;color:#000;vertical-align:middle;line-height:2em}
.frm_update_date_input {height:22px}
.btn_cancel {padding:12px 20px; border:0px; margin:0 5px; }
</style>
<div id="copymove" class="new_win">
<h1 id="win_title"><?php echo $g5['title']; ?></h1>
<form name="fboardmoveall" method="post" action="./category_update.php" onsubmit="return fboardmoveall_submit(this);">
<input type="hidden" name="sw" value="<?php echo $sw; ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<input type="hidden" name="wr_id_list" value="<?php echo $wr_id_list; ?>">
<input type="hidden" name="sca" value="<?php echo $_POST['sca']; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<input type="hidden" name="act" value="<?php echo $act; ?>">
<input type="hidden" name="url" value="<?php echo get_text(clean_xss_tags($_SERVER['HTTP_REFERER'])); ?>">
<div class="tbl_frm_categotry_update tbl_wrap">
<table>
<caption><?php echo $act; ?>한개 이상 선택하여 주십시오.</caption>
<thead>
<tr>
<th scope="col"></th>
<th scope="col">분류목록</th>
</tr>
</thead>
<tbody>
<tr class="">
<th class="td_chk">
<label for="chk0" class="sound_only">[분류없음]</label>
<input type="radio" value="" id="chk0" name="chk_bo_table[]">
</th>
<td>
<label for="chk0">[분류없음]</label>
</td>
</tr>
<?php for ($i=1; $i <= count($list); $i++) {
$atc_mark = '';
$atc_bg = '';
?>
<tr class="<?php echo $atc_bg; ?>">
<th class="td_chk">
<label for="chk<?php echo $i; ?>" class="sound_only"><?php echo $list[$i-1]; ?></label>
<input type="radio" value="<?php echo $list[$i-1]; ?>" id="chk<?php echo $i; ?>" name="chk_category">
</th>
<td>
<label for="chk<?php echo $i; ?>">
<?php echo $list[$i-1]; ?>
<?php echo $atc_mark; ?>
</label>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="win_btn">
<input type="submit" value="<?php echo $act; ?>" id="btn_submit" class="btn_submit">
</div>
</form>
</div>
<script>
$(function() {
$(".win_btn").append("<button type=\"button\" class=\"btn_cancel\">창닫기</button>");
$(".win_btn button").click(function() {
window.close();
});
});
function all_checked(sw) {
var f = document.fboardmoveall;
for (var i=0; i<f.length; i++) {
if (f.elements[i].name == "chk_bo_table[]")
f.elements[i].checked = sw;
}
}
function fboardmoveall_submit(f)
{
var check = false;
if (typeof(f.elements['chk_category']) == 'undefined')
;
else {
if (typeof(f.elements['chk_category'].length) == 'undefined') {
if (f.elements['chk_category'].checked)
check = true;
} else {
for (i=0; i<f.elements['chk_category'].length; i++) {
if (f.elements['chk_category'][i].checked) {
check = true;
break;
}
}
}
}
if (!check) {
alert('게시물의 분류를 선택하세요.');
return false;
}
document.getElementById('btn_submit').disabled = true;
f.action = './category_update.php';
return true;
}
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');
?>
4. 그누보드5 / skin / board / 폴더 / category_update.php 생성
<?php
include_once('./_common.php');
// 게시판 관리자 이상 복사, 이동 가능
if ($is_admin != 'board' && $is_admin != 'group' && $is_admin != 'super')
alert_close('게시판 관리자 이상 접근이 가능합니다.');
if ($sw != 'cate')
alert('sw 값이 제대로 넘어오지 않았습니다.');
if(!count($_POST['chk_category']))
alert('게시물 '.$act.'할 분류를 선택해 주십시오.', $url);
//새로기록된 분류명
$newcate = $_POST['chk_category'];
$wr_id_list = preg_replace('/[^0-9\,]/', '', $_POST['wr_id_list']);
$category_array = array($wr_id_list);
$sql = " select distinct wr_num, wr_id from `{$write_table}` where wr_id in ({$wr_id_list}) order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
$wr_id = $row['wr_id'];
for ($i=0; $i<count($wr_id_list); $i++)
{
$sql2 = " update `{$write_table}` set ca_name = '{$newcate}' where wr_id = '{$wr_id}' ";
$result2 = sql_query($sql2);
$sql2 = " select * from `{$write_table}` where wr_parent = '{$wr_id}' ";
$result2 = sql_query($sql2);
$row2 = sql_fetch_array($result2);
if ($row2['wr_id']) {
$sql3 = " update `{$write_table}` set ca_name = '{$newcate}' where wr_parent = '{$wr_id}' ";
$result3 = sql_query($sql3);
}
}
}
$msg = '분류를 '.$newcate.'로 변경 하였습니다.';
$opener_href = G5_BBS_URL."/board.php?bo_table={$bo_table}&sca={$_POST['sca']}&page={$_POST['page']}";
?>
<meta charset="utf-8">
<script>
alert("<?php echo $msg; ?>");
opener.document.location.href = "<?php echo $opener_href; ?>";
window.close();
</script>
<noscript>
<p>
<?php echo $msg; ?>
</p>
<a href="<?php echo $opener_href; ?>">돌아가기</a>
</noscript>
참고자료
https://sir.kr/g5_tip/2505
SIR 동일강좌 https://sir.kr/g5_tip/5177
<li><input type="submit" name="btn_submit" value="선택이동" onclick="document.pressed=this.value"></li>
를 아래와 같이 내용 추가
<li><input type="submit" name="btn_submit" value="선택이동" onclick="document.pressed=this.value"></li>
<?php if ($is_category) { ?><li><input type="submit" name="btn_submit" value="분류이동" onclick="document.pressed=this.value"></li><?php } ?>
1-2. 그누보드5 / skin / board / 폴더 / list.skin.php
if(document.pressed == "선택이동") {
select_copy("move");
return;
}
를 아래와 같이 내용 추가
if(document.pressed == "선택이동") {
select_copy("move");
return;
}
if(document.pressed == "분류이동") {
select_cate();
return;
}
1-3. 그누보드5 / skin / board / 폴더 / list.skin.php 맨끝
</script>
<?php } ?>
를 아래와 같이 내용 추가
//선택한 게시물의 분류를 변경함
function select_cate() {
var f = document.fboardlist;
str = "분류이동";
var sub_win = window.open("", "cate", "left=50, top=50, width=500, height=550, scrollbars=1");
f.sw.value = "cate";
f.target = "cate";
f.action = "<?php echo $board_skin_url; ?>/category.php";
f.submit();
}
</script>
<?php } ?>
2. 그누보드5 / skin / board / 폴더 / _common.php 생성
<?php
include_once('../../../common.php');
// 테마 폴더 스킨폴더 이용할때 아래꺼 사용
//include_once('../../../../../common.php');
?>
3. 그누보드5 / skin / board / 폴더 / category.php 생성
<?php
include_once('./_common.php');
$act = "분류이동";
// 게시판 관리자 이상 복사, 이동 가능
if ($is_admin != 'board' && $is_admin != 'group' && $is_admin != 'super')
alert_close("게시판 관리자 이상 접근이 가능합니다.");
$g5['title'] = '게시물 ' . $act;
include_once(G5_PATH.'/head.sub.php');
$wr_id_list = '';
if ($wr_id)
$wr_id_list = $wr_id;
else {
$comma = '';
for ($i=0; $i<count($_POST['chk_wr_id']); $i++) {
$wr_id_list .= $comma . $_POST['chk_wr_id'][$i];
$comma = ',';
}
}
$catelist = $board['bo_category_list'];
$list = explode('|',$catelist);
?>
<style>
.tbl_frm_categotry_update {margin:0 0 20px}
.tbl_frm_categotry_update table {width:100%;border-collapse:collapse;border-spacing:0}
.tbl_frm_categotry_update th {padding:5px 3px;border:1px solid #e9e9e9;border-left:0;background:#f5f8f9;text-align:center}
.tbl_frm_categotry_update td {padding:5px 3px;border-top:1px solid #e9e9e9;border-bottom:1px solid #e9e9e9;background:transparent}
.tbl_frm_categotry_update textarea, .frm_update_date_input {border:1px solid #e4eaec;background:#f7f7f7;color:#000;vertical-align:middle;line-height:2em}
.frm_update_date_input {height:22px}
.btn_cancel {padding:12px 20px; border:0px; margin:0 5px; }
</style>
<div id="copymove" class="new_win">
<h1 id="win_title"><?php echo $g5['title']; ?></h1>
<form name="fboardmoveall" method="post" action="./category_update.php" onsubmit="return fboardmoveall_submit(this);">
<input type="hidden" name="sw" value="<?php echo $sw; ?>">
<input type="hidden" name="bo_table" value="<?php echo $bo_table; ?>">
<input type="hidden" name="wr_id_list" value="<?php echo $wr_id_list; ?>">
<input type="hidden" name="sca" value="<?php echo $_POST['sca']; ?>">
<input type="hidden" name="page" value="<?php echo $page; ?>">
<input type="hidden" name="act" value="<?php echo $act; ?>">
<input type="hidden" name="url" value="<?php echo get_text(clean_xss_tags($_SERVER['HTTP_REFERER'])); ?>">
<div class="tbl_frm_categotry_update tbl_wrap">
<table>
<caption><?php echo $act; ?>한개 이상 선택하여 주십시오.</caption>
<thead>
<tr>
<th scope="col"></th>
<th scope="col">분류목록</th>
</tr>
</thead>
<tbody>
<tr class="">
<th class="td_chk">
<label for="chk0" class="sound_only">[분류없음]</label>
<input type="radio" value="" id="chk0" name="chk_bo_table[]">
</th>
<td>
<label for="chk0">[분류없음]</label>
</td>
</tr>
<?php for ($i=1; $i <= count($list); $i++) {
$atc_mark = '';
$atc_bg = '';
?>
<tr class="<?php echo $atc_bg; ?>">
<th class="td_chk">
<label for="chk<?php echo $i; ?>" class="sound_only"><?php echo $list[$i-1]; ?></label>
<input type="radio" value="<?php echo $list[$i-1]; ?>" id="chk<?php echo $i; ?>" name="chk_category">
</th>
<td>
<label for="chk<?php echo $i; ?>">
<?php echo $list[$i-1]; ?>
<?php echo $atc_mark; ?>
</label>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<div class="win_btn">
<input type="submit" value="<?php echo $act; ?>" id="btn_submit" class="btn_submit">
</div>
</form>
</div>
<script>
$(function() {
$(".win_btn").append("<button type=\"button\" class=\"btn_cancel\">창닫기</button>");
$(".win_btn button").click(function() {
window.close();
});
});
function all_checked(sw) {
var f = document.fboardmoveall;
for (var i=0; i<f.length; i++) {
if (f.elements[i].name == "chk_bo_table[]")
f.elements[i].checked = sw;
}
}
function fboardmoveall_submit(f)
{
var check = false;
if (typeof(f.elements['chk_category']) == 'undefined')
;
else {
if (typeof(f.elements['chk_category'].length) == 'undefined') {
if (f.elements['chk_category'].checked)
check = true;
} else {
for (i=0; i<f.elements['chk_category'].length; i++) {
if (f.elements['chk_category'][i].checked) {
check = true;
break;
}
}
}
}
if (!check) {
alert('게시물의 분류를 선택하세요.');
return false;
}
document.getElementById('btn_submit').disabled = true;
f.action = './category_update.php';
return true;
}
</script>
<?php
include_once(G5_PATH.'/tail.sub.php');
?>
4. 그누보드5 / skin / board / 폴더 / category_update.php 생성
<?php
include_once('./_common.php');
// 게시판 관리자 이상 복사, 이동 가능
if ($is_admin != 'board' && $is_admin != 'group' && $is_admin != 'super')
alert_close('게시판 관리자 이상 접근이 가능합니다.');
if ($sw != 'cate')
alert('sw 값이 제대로 넘어오지 않았습니다.');
if(!count($_POST['chk_category']))
alert('게시물 '.$act.'할 분류를 선택해 주십시오.', $url);
//새로기록된 분류명
$newcate = $_POST['chk_category'];
$wr_id_list = preg_replace('/[^0-9\,]/', '', $_POST['wr_id_list']);
$category_array = array($wr_id_list);
$sql = " select distinct wr_num, wr_id from `{$write_table}` where wr_id in ({$wr_id_list}) order by wr_id ";
$result = sql_query($sql);
while ($row = sql_fetch_array($result))
{
$wr_id = $row['wr_id'];
for ($i=0; $i<count($wr_id_list); $i++)
{
$sql2 = " update `{$write_table}` set ca_name = '{$newcate}' where wr_id = '{$wr_id}' ";
$result2 = sql_query($sql2);
$sql2 = " select * from `{$write_table}` where wr_parent = '{$wr_id}' ";
$result2 = sql_query($sql2);
$row2 = sql_fetch_array($result2);
if ($row2['wr_id']) {
$sql3 = " update `{$write_table}` set ca_name = '{$newcate}' where wr_parent = '{$wr_id}' ";
$result3 = sql_query($sql3);
}
}
}
$msg = '분류를 '.$newcate.'로 변경 하였습니다.';
$opener_href = G5_BBS_URL."/board.php?bo_table={$bo_table}&sca={$_POST['sca']}&page={$_POST['page']}";
?>
<meta charset="utf-8">
<script>
alert("<?php echo $msg; ?>");
opener.document.location.href = "<?php echo $opener_href; ?>";
window.close();
</script>
<noscript>
<p>
<?php echo $msg; ?>
</p>
<a href="<?php echo $opener_href; ?>">돌아가기</a>
</noscript>
참고자료
https://sir.kr/g5_tip/2505
SIR 동일강좌 https://sir.kr/g5_tip/5177
댓글목록
등록된 댓글이 없습니다.