if (!defined('_GNUBOARD_')) exit;
// 그룹별 최신글 불러오기 (없을 경우전체)
// my_latest(스킨명, ,그룹명 ,출력개수, 제목길이, 본글(w)or코맨트(c));
function latestgr($skin_dir="basic", $gr_id="", $rows=5, $subject_len=40, $type="w")
{
global $config, $g4, $member;
$list = array();
$latestgr_skin_path = "$g4[path]/skin/latestgr/$skin_dir";
$sql_query = "";
if ($type == "w")
$sql_query .= " and a.wr_is_comment = '0' ";
else if($type == "c")
$sql_query .= " and a.wr_is_comment = '1' ";
if ($gr_id)
$sql_query .= " and b.gr_id = '$gr_id' ";
$sql = " select a.bo_table, a.wr_id, c.gr_subject from {$g4['board_new_table']} a, {$g4['board_table']} b, {$g4['group_table']} c
where a.bo_table = b.bo_table and b.gr_id = c.gr_id and b.bo_use_search = '1' $sql_query order by a.bn_id desc limit 0, $rows";
$result = sql_query($sql);
$gr_subject = "";
for ($i=0; $row = sql_fetch_array($result); $i++){
$tmp_table = $g4['write_prefix'] . $row[bo_table]; // 게시판 테이블
$sql_table = " select wr_id, mb_id, wr_subject, wr_option, wr_content, wr_comment, wr_parent, wr_datetime, wr_last, wr_homepage, wr_name, wr_reply, wr_link1, wr_link2, wr_file, ca_name, wr_hit, wr_is_comment from $tmp_table where wr_id = '$row[wr_id]' ";
$row_table = sql_fetch($sql_table);
$sql_board = " select bo_table, bo_notice, bo_subject, bo_subject_len, bo_use_list_content, bo_new, bo_use_sideview, bo_hot, bo_use_search from $g4[board_table] where bo_table = '$row[bo_table]'";
$row_board = sql_fetch($sql_board);
$list[$i] = get_list($row_table, $row_board, $latestgr_skin_path, $subject_len);
$list[$i][bo_subject] = $row_board[bo_subject];
$list[$i][bo_table] = $row_board[bo_table];
$gr_subject = $row[gr_subject];
$list[$i][href] = "{$g4['bbs_path']}/board.php?bo_table={$row_board['bo_table']}&wr_id={$list[$i]['wr_id']}";
}
ob_start();
include ("$latestgr_skin_path/latestgr.skin.php");
$content = ob_get_contents();
ob_end_clean();
return $content;
}
?>