<?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="chl_edit.php" method="post" name="frm" id="id_frm">
<input type="hidden" name="group_id" value="<?php if(isset($group['group_id'])) { echo $group['group_id'];} elseif (isset($blog['group_id'])) { echo $blog['group_id'];}?>" />
<input type="hidden" name="channel_id" value="<?php if(isset($channel['channel_id'])) { echo $channel['channel_id'];}?>" />

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="760" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_channel'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td valign="top">
						<fieldset>
						<legend><?php echo $lang['txt_header_1'];?></legend>
						<p>
						<?php echo $lang['txt_overview_intro'];?><br />
						</p>
						
						<p>
						<label for="id_channel_title"><?php echo $lang['form_label_title'];?></label>
						<input id="id_channel_title" type="text" name="channel_title" size="35" value="<?php if (isset($channel['channel_title'])) { echo $channel['channel_title'];}?>" /><br />
						</p>
						
						<p>
						<label for="id_channel_url"><?php echo $lang['form_lable_url'];?></label>
						<input id="id_channel_url" type="text" name="channel_url" size="55" value="<?php if (isset($channel['channel_url'])) { echo $channel['channel_url'];}?>" /><br />
						</p>
						
						<p>
						<label for="id_channel_synopsis"><?php echo $lang['form_label_synopsis'];?></label>
						<textarea id="id_channel_synopsis" name="channel_synopsis" cols="52" rows="2"><?php if (isset($channel['channel_synopsis'])) { echo $channel['channel_synopsis'];}?></textarea><br />
						</p>
						</fieldset>
						</td>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="10" height="1" alt="" /><br />
					</td>
					<td valign="top" width="200">
						<fieldset>
						<legend><?php echo $lang['txt_header_2'];?></legend>
						<p>
						<?php echo $lang['txt_publishing_intro'];?><br />
						</p>

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

						<?php
						
						//find out what value rsp has

						if (isset($channel['rsp'])) {
							foreach($channel['rsp'] as $key => $rsp):
								if ($rsp['level_id'] == $rspconfig['rsp_level']['node']) {
									$rsp_node = 1;
								}
							endforeach;
						}
						
						if (isset($group)) {
						?>
						<table border="0" cellspacing="0" cellpadding="4" width="100%">
							<tr>
								<td valign="top">
									<?php
									if ($this->group_acs->checkPermission($resource_ids['group_rsp'], $privilege_ids['allow_rsp_node'])) { //resource_id, Priv_id
										if ($rspconfig['node']['auto_publish'] == 1) {
										    $txt_rsp_node = $lang['form_rsp_node_auto'];
										}
										else {
											$txt_rsp_node = $lang['form_rsp_node'];
										}
									?>
									<input id="id_allow_rsp_node" type="checkbox" name="rsp_node" class="checkbox" value="1" <?php if (isset($rsp_node) && $rsp_node == 1) { echo "checked=\"checked\"";}?> />
								</td>
								<td valign="top">
									<label style="width:100%" for="id_allow_rsp_node"><?php echo $txt_rsp_node;?></label><br />
								</td>
							</tr>
							<?php } ?>
						</table>
						<?php
						}
						else {
						?>

						<script type="text/javascript">
						function setDegreeEveryone(id) {
							if (id.checked) {
								document.getElementById('id_degree_id').checked=true;
							}
						}
						function setPublishingOff() {
							document.getElementById('id_level_id_node').checked=false;
							document.getElementById('id_level_id_public').checked=false;

						}
						</script>

						<table border="0" cellspacing="0" cellpadding="2" width="100%">
							<?php

							if ($this->user_acs->checkPermission($resource_ids['rsp'], $privilege_ids['allow_rsp_node'])) { //resourece_id, Priv_id
							$selected="";
							if (isset($rsp_node) && $rsp_node == 1) {
								$selected=" checked=\"checked\"";
							}
							?>
							<tr>
								<td valign="top">
									<input type="checkbox" id="id_level_id_node" name="rsp_node" value="1"<?php echo $selected;?> class="checkbox" onClick="javascript:setDegreeEveryone(this);" /><br />
								</td>
								<td>
									<?php echo $lang['txt_publish_node_help'];?><br />
								</td>
							</tr>
							<?php }?>
						</table>
						<?php }?>
						</fieldset>

						<script type="text/javascript">
						//check php did not set either of the publishing buttons
						if (document.getElementById('id_level_id_node').checked) {
							document.getElementById('id_degree_id').checked=true;
						}
						</script>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />

						<fieldset>
						<legend><?php echo $lang['txt_header_3'];?></legend>
						<p>
						<?php echo $lang['txt_save_intro'];?><br />
						</p>

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

						<?php if (isset($channel)) {
						?>
						<input type="submit" name="channel_delete" class="button_urgent" value="<?php echo $lang['form_submit_delete'];?>" />&nbsp;
						<input type="submit" name="channel_save" class="button_urgent" value="<?php echo $lang['form_submit_save'];?>" />&nbsp;
						<?php
						}
						else {
						?>
						<input type="submit" name="channel_insert" class="button_urgent" value="<?php echo $lang['form_submit_insert'];?>" /><br />
						<?php }?>
						</fieldset>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>