<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/modules/group/group_space.html
 * 如果您的模型要进行修改，请修改 models/modules/group/group_space.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
	//引入公共模块
	require("foundation/fpages_bar.php");
	require("foundation/module_group.php");
	require("foundation/fcontent_format.php");
	
	//引入语言包
	$g_langpackage=new grouplp;
	$mn_langpackage=new menulp;
	
	//变量区
	$role='';
	$url_uid= short_check(get_argg('user_id'));
	$ses_uid=get_sess_userid();
	$creat_group=get_sess_cgroup();
	$group_id=short_check(get_argg('group_id'));

	//引入模块公共权限过程文件
	$is_self_mode='partLimit';
	$is_login_mode='';
	require("foundation/auser_validate.php");
	
	$button_url="?app=group&user_id=$userid";
	$button_title=$g_langpackage->g_return;
	$tip="<";
	
	$button_mine="content_none";
	$button_his="";

	if($is_self=='Y'){
	$button_mine="";
	$button_his="content_none";		
	$button_url="?app=group_select";
	$button_title=$g_langpackage->g_search;
	$tip="+";
	}

	//当前页面参数
	$page_num=trim(get_argg('page'));
	
	//数据表定义
	$t_groups=$tablePreStr."groups";
	$t_group_members=$tablePreStr."group_members";
	$t_group_subject=$tablePreStr."group_subject";
	$t_group_comment=$tablePreStr."group_subject_comment";
	$t_users=$tablePreStr."users";
	
	//读取方式	
	dbtarget('r',$dbServs);
	$dbo=new dbex;
	
	$subject_rs=array();
	$group_members=array();
	$group_row=array();
	$role='';
	$join_js='';
	//缓存功能区
	require($webRoot.$baseLibsPath."model/group_subject_list.model.cache.php");
	//取得权限
	if($ses_uid){
		$role=pri_limit($dbo,$ses_uid,$group_id);
	}
	//取得群组信息
	$group_row=get_group_info($dbo,$t_groups,$group_id);
	//取得组员
	$group_members=get_new_members($dbo,$t_group_members,$group_id,1);
	$join_js="join_group_var(group_id)";
	if(!isset($ses_uid)){
		$join_js='parent.goLogin()';
	}
	
	//数据显示控制
	$show_data="";
	$show_error="content_none";
	$is_show=1;
	$isNull=0;
	if(empty($subject_rs)){
		$isNull=1;
	}
	$is_admin=get_sess_admin();
	if($is_admin==''){
		if($group_row['group_pass']==0){
			$is_show=0;
			$show_error="";
			$show_data="content_none";
			$error_str=$g_langpackage->g_lock_group;
			}
		}
		
	if(empty($group_row)){
		$show_data="content_none";
		$show_error="";
		$is_show=0;
		$error_str=$g_langpackage->g_data_none;
	}
	
	//操作控制
		$action_ctrl="content_none";
		if($ses_uid!=''){
			if(preg_match("/,$ses_uid,/",$group_row['group_manager_id'])||preg_match("/$ses_uid/",$group_row['add_userid'])){
				$action_ctrl="";
			}
		}
?>
<!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">
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/user_ico_small.css">
<!--[if lt IE 7]>
<style type="text/css">
.uico_photo_small span { behavior: url(skin/<?php echo $skinUrl;?>/css/ie_png_fix.htc);}
</style>
<![endif]-->
<script type="text/javascript" src="skin/default/js/imgfix.js"></script>
<SCRIPT language=JavaScript src="servtools/ajax_client/ajax.js"></SCRIPT>
<script Language="JavaScript">
	
function trim(str){
	return str.replace(/(^\s*)|(\s*$)|(　*)/g , "");
}

function check_form(){
if(trim(document.getElementById("key_word").value)==""){
	parent.Dialog.alert("<?php echo $g_langpackage->g_not_null;?>");
	return false;
	}
}

function join_group(group_id){
	<?php echo $join_js;?>;
}

function join_group_var(group_id){
	var xmlhttp=InitAjax();
	xmlhttp.open("GET","do.php?act=group_join&group_id="+group_id,true);
	xmlhttp.onreadystatechange=function(){
	if(xmlhttp.readyState==4&&xmlhttp.status==200)
		{
		var return_str=xmlhttp.responseText;
		var	return_text=return_str.replace(/[\s\n\r]/g,"");
		parent.Dialog.alert(return_text);
		}
	}
	xmlhttp.send(null);
}

</script>
</head>
<body> 	
  <div class="main_right_title">
     <span class="main_title_dot8"></span>
     <span class="main_title_txt"><?php echo $g_langpackage->g_space;?></span>
  </div>
	<div id="tabsB" class="<?php echo $button_show;?>">
		<ul class="<?php echo $button_mine;?>">
			<li><a href="?app=group" title="<?php echo $g_langpackage->g_mine;?>" class="nowbutl"><span class="nowbutr"><?php echo $g_langpackage->g_mine;?></span></a></li>
			<li><a href="?app=group_hot" title="<?php echo $g_langpackage->g_hot;?>"><span><?php echo $g_langpackage->g_hot;?></span></a></li>
		</ul>
		
			<div class="div_but_2" onclick="location.href='<?php echo $button_url;?>'"><?php echo $button_title;?></div>
			<div class="div_but" onclick="join_group(<?php echo $group_row['group_id'];?>);"><?php echo $g_langpackage->g_click_join;?></div>
	</div>

<?php if($is_show==1){?>

	<?php if($ses_uid!=$group_row['add_userid']&&$ses_uid){?>	
		<div class="rs_head"><span class="right" style="padding-top: 5px;">
			<a class="fenxiang" href="javascript:void(0);" onclick="parent.show_share(1,<?php echo $group_row['group_id'];?>,'<?php echo $group_row['group_name'];?>','','');"><?php echo $mn_langpackage->mn_share;?></a>
			<a class="jubao" href="javascript:void(0);" onclick="parent.report(1,<?php echo $group_row['add_userid'];?>,<?php echo $group_row['group_id'];?>);"><?php echo $mn_langpackage->mn_report;?></a></span><?php echo filt_word($group_row['group_name']);?>
		</div>
  <?php }?>
  
<table class="main <?php echo $show_data;?>">
	
	<tr>
		<th rowspan='2' style="width:120px;height:120px; "><img onerror="parent.pic_error(this)" src=<?php echo $group_row['group_logo'];?> width='120px' height='120px' class='user_ico' /></th>
		<th style="height:28px;"><?php echo $g_langpackage->g_intro;?></th>
		<th><?php echo $g_langpackage->g_gonggao;?></th>
	</tr>
	
	<tr>
		<td style="height:72px;text-align:left;vertical-align:top;width:60%"><?php echo filt_word($group_row['group_resume']);?></td>
		<td style="text-align:left;vertical-align:top;width:40%"><?php echo filt_word($group_row['affiche']);?></td>
	</tr>
	
</table>

<div class="container <?php echo $show_data;?>">
	<div class="rs_head"><?php echo $g_langpackage->g_members;?></div>
</div>
<div style='text-align:left;'>
	<?php foreach($group_members as $rs){?>
			<span class='uico_photo_small' style='height:65px;padding-left:10px;text-align:left'>
				<a href="home.php?h=<?php echo $rs['user_id'];?>" target="_blank">
					<img src=<?php echo $rs['user_ico'];?> onerror="parent.pic_error(this)" width="43px" height="43px" title="<?php echo $rs['user_name'];?>" alt="<?php echo $rs['user_name'];?>" />
				</a>
				<div><?php echo sub_str($rs['user_name'],5,true);?></div>
			</span>
			
	<?php }?>
</div>
<div class="container <?php echo $show_data;?>">
	<div class="rs_head">
		<div class="subject_search">
			<form onsubmit='return check_form();' method="post" action='?app=search_subject&group_id=<?php echo $group_id;?>&user_id=<?php echo $userid;?>'>
				<input type='text' name='key_word' id='key_word' maxlength='10' size='20' style="height: 16px;border:1px #ccc solid" autocomplete='off' />
				<input type='submit' value='<?php echo $g_langpackage->g_search;?>' class="top_button" />
			</form>
			<?php if(isset($role)&&$ses_uid!=''){?>
				<div class="div_but_4" style=''><a href='?app=group_subject&group_id=<?php echo $group_id;?>&user_id=<?php echo $userid;?>'><?php echo $g_langpackage->g_send;?></a></div>
			<?php }?>
		</div>
		<?php echo $g_langpackage->g_bbs;?>
		<span><?php echo str_replace("{t_num}",$group_row['subjects_num'],$g_langpackage->g_topic_num);?></span>
	</div>
</div>

		<?php foreach($subject_rs as $rs){?>
		<div class="poll_list_box">
			<div class="poll_user"><a class="photo" href="home.php?h=<?php echo $rs['user_id'];?>" target="_blank"><img src=<?php echo $rs['user_ico'];?> alt='<?php echo $rs['user_name'];?>' title='<?php echo $rs['user_name'];?>' height='43px' width='43px' /></a><a href="home.php?h=<?php echo $rs['user_id'];?>" target="_blank"><?php echo sub_str($rs['user_name'],6,true);?></a></div>
			<div class="subject_content">
				<dl>
					<dt><a href="?app=group_sub_show&subject_id=<?php echo $rs['subject_id'];?>&group_id=<?php echo $group_id;?>&user_id=<?php echo $userid;?>"><?php echo filt_word($rs['title']);?></a></dt>
					<dd><a href="home.php?h=<?php echo $rs['user_id'];?>" target="_blank"><?php echo filt_word($rs['user_name']);?></a> <span class='gray' style='padding-left:15px'><?php echo str_replace("{date}",$rs['add_time'],$g_langpackage->g_send_time);?></span></dd>
					<dd><span class='gray'><?php echo $g_langpackage->g_read;?>(<?php echo $rs['hits'];?>)</span> <span class='gray' style='padding-left:15px;'><?php echo $g_langpackage->g_re;?>(<?php echo $rs['comments'];?>)</span></dd>
				</dl>
			</div>
			<div class="subject_status"><a href="?app=group_sub_show&subject_id=<?php echo $rs['subject_id'];?>&group_id=<?php echo $group_id;?>&user_id=<?php echo $userid;?>"><?php echo $g_langpackage->g_examine;?></a>
						<a href='do.php?act=group_del_sub&group_id=<?php echo $group_id;?>&subject_id=<?php echo $rs["subject_id"];?>&user_id=<?php echo $userid;?>&sendor_id=<?php echo $rs["user_id"];?>' class="<?php echo $action_ctrl;?>" onclick='return confirm("<?php echo $g_langpackage->g_del_subject;?>");'><?php echo $g_langpackage->g_del;?></a></div>
		</div>
		<?php }?>
	<?php echo page_show($isNull,$page_num,$page_total);?>
<?php }?>

<!--错误控制-->
	<div class="pageerr <?php echo $show_error;?>">
		<?php echo $error_str;?>
	</div>
	
</body>
</html>