<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/modules/group/group_sub_show.html
 * 如果您的模型要进行修改，请修改 models/modules/group/group_sub_show.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
	//引入公共模块
	require("foundation/fpages_bar.php");
	require("foundation/module_group.php");
	
	//引入语言包
	$g_langpackage=new grouplp;
	$mn_langpackage=new menulp;
	
	//变量区
	$url_group_id=short_check(get_argg('group_id'));
	$subject_id=short_check(get_argg('subject_id'));
	$visitor_id=get_sess_userid();
	$visitor_name=get_sess_username();
	$user_id=get_argg('user_id');
	
	//当前页面参数
	$page_num=trim(get_argg('page'));
	
	//读取方式
	dbtarget('r',$dbServs);
	$dbo=new dbex;
	
	//数据表定义
	$t_group_members=$tablePreStr."group_members";
	$t_groups=$tablePreStr."groups";
	$t_group_subject=$tablePreStr."group_subject";
	$t_group_comment=$tablePreStr."group_subject_comment";
	$role='';
	//权限判断
	if($visitor_id!=''){
		$role=pri_limit($dbo,$visitor_id,$url_group_id);
	}
	
	//取得话题评论
	$condition="subject_id=$subject_id";
	$order_by="order by add_time desc";
	$type="getRs";
	$dbo->setPages($set_page_data_num,$page_num);//设置分页
	$comment_rs=get_db_data($dbo,$t_group_comment,$condition,$order_by,$type);
	$page_total=$dbo->totalPage;//分页总数
	
	//取得群组加入方式
	$sql="select group_join_type from $t_groups where group_id=$url_group_id";
	$g_join_type=$dbo->getRow($sql);
	$join_type=$g_join_type['group_join_type'];
	
	//控制评论
		$isNull=0;
		$show_com='';
	if(empty($comment_rs)){
		$isNull=1;
	}

	//取得主题信息
	$condition="group_id=$url_group_id and subject_id=$subject_id";
	$order_by="order by add_time desc";
	$type="getRow";
	$subject_row=get_db_data($dbo,$t_group_subject,$condition,$order_by,$type);
	$host_id=$subject_row['user_id'];
	
	//防止刷新访问量
	if($visitor_id!=get_session('g_'.$subject_id)){
		//写入方式
		dbtarget('w',$dbServs);
		$sql="update $t_group_subject set hits=hits+1 where subject_id='$subject_id'";
		$dbo->exeUpdate($sql);
		set_session('g_'.$subject_id,$visitor_id);
	}

	//权限显示控制
	$is_pri=1;
	$show_error="content_none";
	$error_str="";
	$isset_data="";
	$is_admin=get_sess_admin();
	if($is_admin==''){
		if($role=='' && $join_type!=0){
			$is_pri=0;
			$show_error="";
			$isset_data="content_none";
			$error_str=$g_langpackage->g_arrest;
			$show_com="content_none";
		}
	}
	//显示控制
	if(empty($subject_row)){
		$show_error="";
		$isset_data="content_none";
		$error_str=$g_langpackage->g_data_none;
		$show_com="content_none";
	}	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/row_menus.css">
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/iframe.css">
<script type="text/javascript" src="skin/default/js/imgfix.js"></script>
<script type='text/javascript' src="skin/default/js/jooyea.js"></script>
<script type='text/javascript'>
function setAct(URL){
	window.open(URL,'newwindow','height=346,width=520,top=160,left=250,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
}
</script>
</head>
<body>
  <div class="main_right_title">
     <span class="main_title_dot8"></span>
     <span class="main_title_txt"><?php echo $g_langpackage->g_subject;?></span>
  </div>
  <div id="tabsB">
  <ul>
    <li><a class="nowbutl"><span class="nowbutr"><?php echo $g_langpackage->g_subject;?></span></a></li>
  </ul>
	<div class="div_but_2" onclick="location.href='?app=group_space&group_id=<?php echo $url_group_id;?>&user_id=<?php echo $user_id;?>'">
	<?php echo $g_langpackage->g_re_space;?>
	</div>	
</div>

<?php if(!empty($subject_row)&&$is_pri==1){?>

		<div class="poll_list_box <?php echo $isset_data;?>">
			<div class="poll_user">
				<a class="photo" href="home.php?h=<?php echo $subject_row['uid'];?>" target="_blank">
					<img src=<?php echo $subject_row['user_ico'];?> alt='<?php echo $subject_row['user_name'];?>' title='<?php echo $subject_row['user_name'];?>' height='43px' width='43px' />
				</a>
			</div>
			<div class="subject_content">
				<dl style='float:left'>
					<dt><?php echo filt_word($subject_row['title']);?></dt>
					<dd class="<?php echo $isset_data;?>"><?php echo $g_langpackage->g_editor;?>：<a href="home.php?h=<?php echo $subject_row['user_id'];?>" target="_blank">
				<?php echo filt_word($subject_row['user_name']);?></a> <a href='?app=msg_creator&2id=<?php echo $subject_row["user_id"];?>&nw=1'><?php echo $g_langpackage->g_leave_me;?></a></dd>
					<dd style='padding-top:15px;padding-bottom:15px'><?php echo filt_word($subject_row['content']);?></dd>
					<dd><span class='gray'><?php echo $g_langpackage->g_read;?>(<?php echo $subject_row['hits'];?>)</span> <span style='padding-left:15px' class='gray'><?php echo $g_langpackage->g_re;?>(<?php echo $subject_row['comments'];?>)</span></dd>
				</dl>
			</div>
			<?php if($visitor_id!=$subject_row['user_id']&&$visitor_id){?>
			<div class="subject_status" style="padding-top:0;">
				<a class="fenxiang" href="javascript:void(0);" onclick="parent.show_share(8,<?php echo $subject_row['subject_id'];?>,'<?php echo $subject_row['title'];?>','','');"><?php echo $mn_langpackage->mn_share;?></a>
				<a class="jubao" href="javascript:void(0);" onclick="parent.report(9,<?php echo $subject_row['user_id'];?>,<?php echo $subject_row['subject_id'];?>);"><?php echo $mn_langpackage->mn_report;?></a>
			</div>
			<?php }?>
		</div>
<div class="tleft ml20">
<div class="replytip"></div>
<div id='show_1_<?php echo $subject_row["subject_id"];?>' class="<?php echo $show_com;?>">
<?php foreach($comment_rs as $val){?>
	<div class="reaction" id="record_1_<?php echo $val['comment_id'];?>">
		<?php if(isset($role)&&$role<=1){?>
			<a href="javascript:parent.del_com(<?php echo $val['host_id'];?>,1,<?php echo $val['subject_id'];?>,<?php echo $val['comment_id'];?>,<?php echo $val['visitor_id'];?>)" class="replyclose"></a>
		<?php }?>
		<a href="home.php?h=<?php echo $val["visitor_id"];?>" target="_blank"><img src="<?php echo $val["visitor_ico"];?>" width="43" height="43" /></a>
		<a href="home.php?h=<?php echo $val["visitor_id"];?>" target="_blank"><?php echo $val["visitor_name"];?></a><label><?php echo $val["add_time"];?></label>
		<p class="left"><?php echo $val["content"];?></p>
	</div>
<?php }?>
<div style="text-align:center;background:#ecfbff;width:90%"><?php echo page_show($isNull,$page_num,$page_total);?></div>
</div>
<?php if($role!=''){?>
	<div class="reply">
		<img src='<?php echo get_sess_userico();?>' />
		<textarea id="reply_1_<?php echo $subject_row['subject_id'];?>_input"></textarea>
		<div class="replybt">
			<input class="left button2" onclick="parent.restore_com(<?php echo $subject_row['user_id'];?>,1,<?php echo $subject_row['subject_id'];?>,'');" type="submit" name="button" id="button" value="<?php echo $g_langpackage->g_submit;?>" />
			<a class="right" href="javascript: void(0);" onclick="showim(''); showFace(this,'face_list_menu','reply_1_<?php echo $subject_row['subject_id'];?>_input');"><?php echo $g_langpackage->g_face;?></a>
		</div>
		<div class="clear"></div>
	</div>
</div>
<?php }?>
<?php }?>
	<div class="pageerr <?php echo $show_error;?>">
		<?php echo $error_str;?>
	</div>
	<!-- face begin -->
	<div id="face_list_menu" class="emBg" style="display:none;z-index:100;">
	</div>
	<!-- face end -->
</body>
</html>