<?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_subject_edit.php" method="post">
<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="52" alt="" /><br />

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

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

		<td width="570" valign="top">
			<?php
			if (isset($display) && $display == "preview") {
			?>
			<input type="hidden" name="data[file_id]" value="<?php if(isset($subject['file_id'])) { echo $subject['file_id'];}?>" />
			<input type="hidden" name="data[topic_id]" value="<?php if(isset($subject['topic_id'])) { echo $subject['topic_id'];}?>" />
			<input type="hidden" name="data[subject_title]" value="<?php if(isset($subject['subject_title'])) { echo $subject['subject_title'];}?>" />
			<input type="hidden" name="data[subject_body]" value="<?php if(isset($subject['subject_body'])) { echo $subject['subject_body'];}?>" />
			<input type="hidden" name="data[subject_hidden]" value="<?php if(isset($subject['subject_hidden'])) { echo $subject['subject_hidden'];}?>" />
			<input type="hidden" name="data[subject_locked]" value="<?php if(isset($subject['subject_locked'])) { echo $subject['subject_locked'];}?>" />
			<input type="hidden" name="data[subject_sticky]" value="<?php if(isset($subject['subject_sticky'])) { echo $subject['subject_sticky'];}?>" />
			<input type="hidden" name="data[cms_node]" value="<?php if(isset($subject['cms_node'])) { echo $subject['cms_node'];}?>" />
			<input type="hidden" name="data[cms_group]" value="<?php if(isset($subject['cms_group'])) { echo $subject['cms_group'];}?>" />
			
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td colspan="3" class="txt_title" align="right">
						<?php echo $lang['hdr_subject'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<?php
					if (isset($subject['image'])) {
					?>
					<td valign="top" width="1%">
						<img src="get_file.php?file=<?php echo $subject['image']['file'];?>" border="0" class="picture" title="<?php echo $subject['image']['file_title'];?>"><br />
					</td>
					<?
					}
					?>
					<td valign="top">
						<b><?php echo $lang['hdr_subject'];?>: <?php echo $subject['subject_title'];?></b><br />
						<?php echo $subject['display_subject_body'];?><br />
						</p>
					</td>
					<td class="txt_footer" valign="top" nowrap width="1%">
						<?php
						if (isset($subject['subject_sticky'])) {
							echo $lang['txt_sticky'] . "<br />";
						}

						if (isset($subject['subject_locked'])) {
							echo $lang['txt_locked'] . "<br />";
						}
						
						if (isset($subject['subject_hidden'])) {
							echo $lang['txt_hidden'] . "<br />";
						}
						?>
						<br />
						
					</td>
			    </tr>
				<tr>
					<td valign="top" align="right">
						<input type="submit" name="edit_again" class="formInput" value="<?php echo $lang['sub_edit_again'];?>" />&nbsp;&nbsp;
						<input type="submit" name="insert" class="formInput" value="<?php echo $lang['sub_insert'];?>" /><br />
					
					</td>
				</tr>
			</table>
			<?php
			}
			else {
			?>
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['section_update'];?><br />
						<hr />
					</td>
				</tr>
			</table>
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td valign="top" colspan="2">
						<?php echo $lang['txt_subject_intro'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<table border="0" cellspacing="0" cellpadding="4" width="100%">
							
							<tr>
								<td valign="top" colspan="2">
									<b><?php echo $lang['txt_title'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_title_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="2">
									<input type="text" name="data[subject_title]" class="formInput" size="42" maxlength="250" value="<?php if(isset($subject['subject_title'])) { echo $subject['subject_title'];}?>" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="2">
									<b><?php echo $lang['txt_description'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_description_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="2">
									<textarea name="data[subject_body]" rows="5" cols="40" class="formInput"><?php if (isset($subject['subject_body'])) { echo $subject['subject_body'];}?></textarea><br />
								</td>
							</tr>
						</table>
					</td>
					<td valign="top">
						<table border="0" cellspacing="0" cellpadding="4" width="100%">
							<tr>
								<td>
									<b><?php echo $lang['txt_topic'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_topic_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td>
									<select name="data[topic_id]" class="formInput">
									<?php
									foreach($topics as $key => $i):
									$selected = "";
			
									if ($topic_id == $i['topic_id']) {
									    $selected = "selected";
									}
									?>
			
									<option value="<?php echo $i['topic_id'];?>" <?php echo $selected;?>><?php echo $i['topic_title'];?></option>
									<?php endforeach; ?>
									</select>
								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $lang['txt_sticky_locked'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_sticky_locked_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td>
									<input type="checkbox" name="data[subject_locked]" value="1" <?php if (isset($subject['subject_locked']) && $subject['subject_locked'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $lang['txt_locked'];?><br />
									<input type="checkbox" name="data[subject_sticky]" value="1" <?php if (isset($subject['subject_sticky']) && $subject['subject_sticky'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $lang['txt_sticky'];?><br />
								</td>
							</tr>
							<?php
							if ($this->group_acs->checkPermission($resource_ids['group_forum'], $privilege_ids['allow_hidden'])) { //resource_id, Priv_id
							?>
							<tr>
								<td>
									<b><?php echo $lang['txt_hidden'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_hidden_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td>
									<input type="checkbox" name="data[subject_hidden]" value="1" <?php if (isset($subject['subject_hidden']) && $subject['subject_hidden'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $lang['txt_hidden'];?><br />
								</td>
							</tr>
							<?php  }?>
						</table>
					</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 colspan="2" class="txt_title" align="right">
						<?php echo $lang['section_cms'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_public'])) { //resource_id, Priv_id
							if ($cms_node_auto_publish == 1) {
							    $txt_cms_node = $lang['txt_cms_node_auto'];
							}
							else {
								$txt_cms_node = $lang['txt_cms_node'];
							}
							
						?>
						<input type="checkbox" name="data[cms_node]" value="1" <?php if (isset($subject['cms_node']) && $subject['cms_node'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_node;?><br />
						<?php
						}
						
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_group_home'])) { //resource_id, Priv_id
							if ($group['group_cms_auto_publish'] == 1) {
							    $txt_cms_group = $lang['txt_cms_group_auto'];
							}
							else {
								$txt_cms_group = $lang['txt_cms_group'];
							}
						?>
						<input type="checkbox" name="data[cms_group]" value="1" <?php if (isset($subject['cms_group']) && $subject['cms_group'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_group;?><br />
						<?php } ?>
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php
			if (isset($images)) {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td colspan="<?php echo $images_per_row;?>" class="txt_title" align="right">
						<?php echo $lang['hdr_images'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<span class="txt_footer"><?php echo $lang['txt_images_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<input type="radio" value="0" name="data[subject_image_id]" checked />&nbsp;no image<br />
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="2">
							<tr>
								<?php
								$images_per_row = 6;
								$r = 0;
								foreach($images as $key => $i):
			
			
								$selected = "";
									if (isset($subject['file_id']) && $subject['file_id'] == $i['file_id']) {
									    $selected = "checked";
									}
			
								?>
			
								<td valign="top">
									<img src="get_file.php?file=<?php echo $i['file']; ?>" border="0" class="picture" /><br />
									<input type="radio" value="<?php echo $i['file_id'];?>" name="data[file_id]" <?php echo $selected;?> /><br />
								</td>
			
								<?php
								$r++;
								if ($r == $images_per_row) {
								    echo "</tr><tr>";
									$r=0;
								}
			
								endforeach;
								if ($r != $images_per_row) {
									$r = $images_per_row-$r;
									print "<td colspan=" . $r . "><br /></td>";
								}
								?>
							</tr>
						</table>
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['section_publishing'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="2">
						<?php echo $lang['txt_subject_publish'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top" align="right">
						<input type="submit" name="preview" class="formInput" value="<?php echo $lang['sub_preview'];?>" />&nbsp;&nbsp;
						<input type="submit" name="insert" class="formInput" value="<?php echo $lang['sub_insert'];?>" /><br />
					
					</td>
				</tr>
			</table>
			<?php
			}
			?>
		</td>
	</tr>
</table>
</form>
