<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

?>


<form action="g_forum.php" method="post" name="action">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>" />

<table width="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "g_menu.inc.tpl.php";
			?>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title">
						<?php echo $lang['section_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_forum'], $privilege_ids['allow_edit'])) { //resource_id, Priv_id
						?>
						<a href="g_forum_topic_edit.php?group_id=<?php echo $group['group_id'];?>" class="txt_sub_menu"><?php echo $lang['href_edit_topics'];?></a><br />
						
						<a href="g_forum_subject_edit.php?group_id=<?php echo $group['group_id'];?>" class="txt_sub_menu"><?php echo $lang['href_add_subject'];?></a><br />
						<?php
						}
						?>
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title" colspan="2">
						<?php echo $lang['section_search'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<?php echo $lang['txt_search_discussions'];?><br />
					</td>
			    <tr>
					<td colspan="2">
						<input type="text" name="search_text" size="18" class="formInput" value="<?php if(isset($search)) { echo $search;}?>" /><br />
					</td>
			    </tr>
				<tr>
					<td align="right" colspan="2">
						<input type="submit" name="search" value="<?php echo $lang['sub_search'];?>" class="formInput" /><br />
					</td>
				</tr>
				<?php 
				if(isset($search)) {
				?>
				<tr>
					<td>
						<?php echo count($topics) . " " . $lang['txt_search_found'];?><br />
					</td>
					<td align="right">
						<a href="g_forum.php?group_id=<?php echo $group['group_id'];?>"><?php echo $lang['href_search_show_all'];?></a><br />
					</td>
				</tr>
				<?php }?>
			</table>
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="52" alt="" /><br />

			<?php
			include $templatePath . "logo.inc.tpl.php";
			?>
		</td>

		<td width="20">&nbsp;</td>

		<td width="570" valign="top">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($topics)) {
				foreach($topics as $key => $r):
				?>
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $r['topic_title'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $r['topic_synopsis'];?><br />
					</td>
					<td align="right">
						<?php if ($r['topic_hidden'] == 1) { echo $lang['txt_hidden'];}?><br />
					</td>
				</tr>
				
				
				
				<?php
				if (!empty($r['subjects'])) {
				foreach($r['subjects'] as $key => $i):

				$url = "g_forum_subject.php?group_id=" . $group['group_id'] . "&amp;subject_id=" . $i['subject_id'];

				?>
				<tr>
					<td colspan="2">
						<table width="100%" cellpadding="0" cellspacing="0" border="0" class="picture">
							<tr>
								<td>
									<table width="100%" cellpadding="4" cellspacing="2" border="0">
										<tr>
											<td valign="middle" width="36" align="center" height="28">
												<a href="<?php echo $url;?>" title="<?php echo $i['subject_title'];?>"><img src="<?php echo $templatePath;?>img/sn.png" border="0" width="28" height="28" alt="" /></a><br />
											</td>
											<td valign="top" class="bg4">
												<?php echo $lang['txt_subject_datetime'];?>: <?php echo $i['subject_create_datetime'];?><br />
												<a href="<?php echo $url;?>" title="<?php echo $i['subject_title'];?>"><?php echo $i['subject_title'];?></a><br />
												<span  class="txt_footer">
												<?php echo dots(140,$i['subject_body']);?><br />
												</span>
											</td>
											<td valign="top" class="bg3" width="20%">
												<span  class="txt_footer">
												<?php echo $lang['txt_comment_total'];?>: <?php echo $i['comment_total'];?><br />
												<?php if (!empty($i['last_comment']['comment_create_datetime'])) { echo $lang['txt_last_comment'] . ": " . $i['last_comment']['comment_create_datetime'] . "<br />";}?>
												
												<?php
												if (isset($i['movement']['lastview_datetime'])) {
													echo $lang['txt_watching'] . ": " . $lang['txt_lastview'] . " " . $i['movement']['lastview_datetime'] . "<br />";
													echo "(" . $lang['txt_movement'] . " ". $i['movement']['movement'] . ")";
												}
												?>
												
												<?php
												if (isset($i['subject_sticky'])) {
													echo $lang['txt_sticky'] . ", ";
												}
						
												if (isset($i['subject_locked'])) {
													echo $lang['txt_locked'] . ", ";
												}
						
												if (isset($i['subject_hidden'])) {
													echo $lang['txt_hidden'];
												}
												?>
												<br />
												</span>
											</td>
											<td width="28" valign="middle" align="center">
												<a href="<?php echo $url;?>"><img src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture" title="<?php echo $i['image']['file_title'];?>"></a><br />
											</td>
									    </tr>
									</table>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td>
						<?php echo $lang['err_no_subjects'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_topics'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['err_no_topics'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
		</td>
	</tr>
</table>
</form>
