<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2006 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., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

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

<div class="box">
	<div class="box_top">
		<?php echo $lang['hdr_channel'];?><br />
	</div>
	
	<div class="box_mid">
		<div class="content">
			<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" class="input" 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_label_url'];?></label>
						<input id="id_channel_url" type="text" class="input" 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>
						
						<p>
						<label for="id_channel_type"><?php echo $lang['form_label_type'];?></label>
							<select name="channel_type_id">
							<option value="" selected="selected"><?php echo $lang['txt_none'];?></option>
							<?php foreach($lang['channel']['type'] as $key => $i): ?>
								<option value="<?php echo $key;?>" <?php if(isset($channel) && $channel['channel_type_id'] == $key) echo "selected=\"selected\"";?>><?php echo $i;?></option>
							<?php endforeach; ?>
							</select>
						</p>
						
						<?php
							if (count($me['language_ids']) > 1) {
							?>
							<p>
							<label for="id_languages"><?php echo $lang['form_label_language'];?></label>
							<select name="language_id">
							<?php foreach($me['language_ids'] as $key => $i): ?>
								<?php
								if (isset($lang['arr_lang_name'][$i])) {
								?>
								<option value="<?php echo $i;?>" <?php if(isset($channel) && $channel['language_id'] == $i) echo "selected=\"selected\"";?>><?php echo $lang['arr_lang_name'][$i];?></option>
								<?php }?>
							<?php endforeach; ?>
							</select>
							</p>
						<?php }?>
						
						</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['txt_publish_auto_node_help'];
										}
										else {
											$txt_rsp_node = $lang['txt_publish_node_help'];
										}
									?>
									<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['node']['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="input_submit" value="<?php echo $lang['sub_delete'];?>" />&nbsp;
						<input type="submit" name="channel_save" class="input_submit" value="<?php echo $lang['sub_save'];?>" />&nbsp;
						<?php
						}
						else {
						?>
						<input type="submit" name="channel_insert" class="input_submit" value="<?php echo $lang['sub_add'];?>" /><br />
						<?php }?>
						</fieldset>
					</td>
				</tr>
			</table>
		</div>
	</div>
</div>
		
<div class="box_bottom">
	<span class="box_bottom_right"></span>
	<span class="box_bottom_left"></span>
</div>