#!/usr/local/bin/php
<?php 
/*
	Copyright (C) 2008 Giovanni Vallesi
	Copyright (C) 2008, 2009 CAST MediaTel <http://www.castmediatel.com/>.
	All rights reserved.

	part of a package for AskoziaPBX (http://askozia.com/pbx)
	Copyright (C) 2008 IKT <http://itison-ikt.de>.
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:
	
	1. Redistributions of source code must retain all the above copyrights notices,
	   this list of conditions and the following disclaimer.
	
	2. Redistributions in binary form must reproduce all the above copyrights
	   notices, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.
	
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

require_once("guiconfig.inc");
require_once($config['system']['astmedia.pkg']['env']['includepath'] . '/constants.inc');
require_once($config['system']['astmedia.pkg']['env']['includepath'] . '/functions.inc');
$pgtitle = array('Package', PKG_TITLE);
//
if($_POST)
{
	$gui_config = array();
	foreach($config['system']['astmedia.pkg']['opt'] as $c_key => $c_value)
	{
		$gui_config[$c_key] = 0;
		if(isset($_POST[$c_key]))
		{
			$gui_config[$c_key] = 1;
		}
	}
	if(pkgopt_set($gui_config) == 0)
	{
		$savemsg = get_std_save_message($retval);
	}
	//
	unset($gui_config);
	log_msg();
}
if($_GET)
{
	
}
$gui_config = $config['system']['astmedia.pkg']['opt'];
/*
	begin html output
*/
include("fbegin.inc");
?>
<script language="JavaScript">
<!--
function enable_change(enable_over) {
}
// -->
</script>
<?php if ($savemsg) display_info_box($savemsg); ?>
<form action="<?php echo PKG_INDEXLINK; ?>" name="pamset" id="pamset" method="post">
	<table>
		<tr>
			<td colspan="2" class="listtopic">Select which Asterisk files you want in the live storage media</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">Sounds</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="sounds" id="sounds" value="yes" <?php if ($gui_config['sounds'] == 1) echo "checked"; ?>>
				<label for="sounds" style="">Enable to use custom sounds/prompts</label>
				<div class="vexpl" style="margin: 0.4em;">
					Systems files will be copied to:<br><?php echo PKG_MEDIAROOT . PKG_SOUNDS;?><br>
					Put your files here to add other Asterisk prompts and/or customized files in the &laquo;custom&raquo; subdirectory.<br>
					Dependig on current platform this may require some time to complete when applying changes.
				</div>
			</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">MOH</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="moh" id="moh" value="yes" <?php if ($gui_config['moh'] == 1) echo "checked"; ?>>
				<label for="sounds" style="">Enable to use custom moh files.</label>
				<div class="vexpl" style="margin: 0.4em;">
					Current moh file will be copied to:<br>
					<?php echo PKG_MEDIAROOT . PKG_MOH;?><br>Add your moh file here to deliver custom music on old.
				</div>
			</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">DB</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="astdb" id="astdb" value="yes" <?php if ($gui_config['astdb'] == 1) echo "checked"; ?>>
				<label for="astdb" style="">Make the Asterisk db persistent.</label>
				<div class="vexpl" style="margin: 0.4em;">
					Useful if you need to keep states between restart in some application.
				</div>
			</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">AGI</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="agibin" id="agibin" value="yes" <?php if ($gui_config['agibin'] == 1) echo "checked"; ?>>
				<label for="agibin" style="">The agi bin directory.</label>
				<div class="vexpl" style="margin: 0.4em;">
					Put your custom agi scripts in:<br><?php echo PKG_MEDIAROOT . PKG_AGIBIN;?>
				</div>
			</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">Keys</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="keys" id="keys" value="yes" <?php if ($gui_config['keys'] == 1) echo "checked"; ?>>
				<label for="keys" style="">Public keys.</label>
				<div class="vexpl" style="margin: 0.4em;">
					Public keys used for providers/devices auth. can be saved to:<br>
					<?php echo PKG_MEDIAROOT . PKG_KEYS;?>
					</div>
			</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">Voicemail</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="voicemail" id="voicemail" value="yes" <?php if ($gui_config['voicemail'] == 1) echo "checked"; ?>>
				<label for="voicemail" style="">Enable to use custom Voicemail prompts.</label>
				<div class="vexpl" style="margin: 0.4em;">
					Mail boxes tree will be in:<br><?php echo PKG_MEDIAROOT . PKG_VOICEMAIL;?>
				</div>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="listtopic">Additional Asterisk modules/applications</td>
		</tr>
		<tr>
			<td class="vncellreq" valign="top" width="20%">Modules</td>
			<td class="vtable" width="80%">
				<input type="checkbox" name="xmod" id="xmod" value="yes" <?php if ($gui_config['xmod'] == 1) echo "checked"; ?>>
				<label for="xmod" style="">Enable to use custom modules/applications</label>
				<div class="vexpl" style="margin: 0.4em;">
					New modules will be linked from:<br><?php echo PKG_MEDIAROOT . PKG_MODULES;?><br>
					Hint: <b>deactivate this option before</b> adding/deteting any file in the directory.<br>
					Package distribution came with app_record.so included (required to record from dialplan, voicemail prompts from extensions...).
				</div>
			</td>
		</tr>
	</table>
	<div align="center">
		<div style="margin: 0.8em;"><span class="red"><b>Warning:</b></span> Saving settings will restart the PBX process<br>(all current calls will be dropped!)</div>
		<input name="submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
	</div>
</form>
<script language="JavaScript">
<!--
enable_change(false);
//-->
</script>
<?php include("fend.inc"); ?>
