diff options
Diffstat (limited to 'packages/freeswitch/freeswitch_dialplan_includes_edit.tmp')
-rw-r--r-- | packages/freeswitch/freeswitch_dialplan_includes_edit.tmp | 523 |
1 files changed, 523 insertions, 0 deletions
diff --git a/packages/freeswitch/freeswitch_dialplan_includes_edit.tmp b/packages/freeswitch/freeswitch_dialplan_includes_edit.tmp new file mode 100644 index 00000000..74b17272 --- /dev/null +++ b/packages/freeswitch/freeswitch_dialplan_includes_edit.tmp @@ -0,0 +1,523 @@ +<?php +/* $Id$ */ +/* + + freeswitch_dialplan_includes_edit.php + Copyright (C) 2008 Mark J Crane + All rights reserved. + + FreeSWITCH (TM) + http://www.freeswitch.org/ + + 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 the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, 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("guiconfig.inc"); +require("/usr/local/pkg/freeswitch.inc"); + + +//freeswitchdialplanincludes + //dialplanincludeid + //extensionname + //context + //default + //enabled + //descr + +// + + + +$a_dialplan_includes = &$config['installedpackages']['freeswitchdialplanincludes']['config']; +$a_dialplan_include_details = &$config['installedpackages']['freeswitchdialplanincludedetails']['config']; + +$id = $_GET['id']; +if (isset($_POST['id'])) { + $id = $_POST['id']; +} +$parentid = $id; + + +if (isset($id) && $a_dialplan_includes[$id]) { + $pconfig['dialplanincludeid'] = $a_dialplan_includes[$id]['dialplanincludeid']; + $dialplanincludeid = $a_dialplan_includes[$id]['dialplanincludeid']; + $pconfig['extensionname'] = $a_dialplan_includes[$id]['extensionname']; + $pconfig['order'] = $a_dialplan_includes[$id]['order']; + $pconfig['context'] = $a_dialplan_includes[$id]['context']; + $pconfig['enabled'] = $a_dialplan_includes[$id]['enabled']; + $pconfig['descr'] = $a_dialplan_includes[$id]['descr']; + $pconfig['opt1name'] = $a_dialplan_includes[$id]['opt1name']; + $pconfig['opt1value'] = $a_dialplan_includes[$id]['opt1value']; +} + +if ($_POST) { + + unset($input_errors); + $pconfig = $_POST; + + if ($_GET['act'] == "del") { + if ($_GET['type'] == 'dialplanincludedetails') { + if ($a_dialplan_include_details[$_GET['id']]) { + unset($a_dialplan_include_details[$_GET['id']]); + write_config(); + sync_package_freeswitch_dialplan_includes(); + header("Location: freeswitch_dialplan_include_edit.php?id=".$_GET['id']); + exit; + } + } + } + + + if (!$input_errors) { + + $ent = array(); + if (strlen($_POST['dialplanincludeid']) > 0) { + //update + $ent['dialplanincludeid'] = $_POST['dialplanincludeid']; + } + else { + //add + $ent['dialplanincludeid'] = guid(); + } + $ent['extensionname'] = $_POST['extensionname']; + $ent['order'] = $_POST['order']; + //$ent['context'] = $_POST['context']; + $ent['context'] = 'default'; + $ent['enabled'] = $_POST['enabled']; + $ent['descr'] = $_POST['descr']; + $ent['opt1name'] = $_POST['opt1name']; + $ent['opt1value'] = $_POST['opt1value']; + + + if (isset($id) && $a_dialplan_includes[$id]) { + + foreach($config['freeswitchdialplanincludes']['config'] as $rowhelper) { + + //$rowhelper['dialplanincludeid']; + //$rowhelper['extensionname']; + //$rowhelper['context']; + //$rowhelper['enabled']; + + $filenamechanged = false; + if ($rowhelper['dialplanincludeid'] == $_POST['dialplanincludeid']) { + + if ($rowhelper['extensionname'] != $_POST['extensionname']) { + //if the extension name has changed then remove the current dialplan xml file + //to prepare for the new file + $filenamechanged = true; + } + if ($rowhelper['order'] != $_POST['order']) { + //if the order has changed then remove the current dialplan xml file + //to prepare for the new file + $filenamechanged = true; + } + if ($_POST['enabled'] == "false") { + //if the extension name is disabled then remove the dialplan xml file + $filenamechanged = true; + } + if ($filenamechanged){ + $dialplanincludefilename = $rowhelper['order']."_".$rowhelper['extensionname'].".xml"; + if (file_exists("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename)) { + unlink("/usr/local/freeswitch/conf/dialplan/default/".$dialplanincludefilename); + } + unset($dialplanincludefilename); + } + + } + unset($filenamechanged); + + } //end foreach + + //update the config + $a_dialplan_includes[$id] = $ent; + } + else { + //add to the config + $a_dialplan_includes[] = $ent; + } + + + write_config(); + sync_package_freeswitch_dialplan_includes(); + + header("Location: freeswitch_dialplan_includes.php"); + exit; + } +} + +$pgtitle = "FreeSWITCH: Dialplan: Edit"; +include("head.inc"); + +?> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle"><?=$pgtitle?></p> + +<?php if ($input_errors) print_input_errors($input_errors); ?> + + +<div id="mainlevel"> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> +<tr><td class="tabnavtbl"> +<?php + + $tab_array = array(); + $tab_array[] = array(gettext("Settings"), false, "/pkg_edit.php?xml=freeswitch.xml&id=0"); + $tab_array[] = array(gettext("Dialplan"), true, "/freeswitch/freeswitch_dialplan_includes.php"); + $tab_array[] = array(gettext("Extensions"), false, "/pkg.php?xml=freeswitch_extensions.xml"); + $tab_array[] = array(gettext("External"), false, "/pkg_edit.php?xml=freeswitch_external.xml&id=0"); + $tab_array[] = array(gettext("Gateways"), false, "/freeswitch/freeswitch_gateways.php"); + $tab_array[] = array(gettext("Internal"), false, "/pkg_edit.php?xml=freeswitch_internal.xml&id=0"); + $tab_array[] = array(gettext("IVR"), false, "/freeswitch/freeswitch_ivr.php"); + $tab_array[] = array(gettext("Modules"), false, "/pkg_edit.php?xml=freeswitch_modules.xml&id=0"); + $tab_array[] = array(gettext("Public"), false, "/freeswitch/freeswitch_public_includes.php"); + $tab_array[] = array(gettext("Rec"), false, "/freeswitch/freeswitch_recordings.php"); + $tab_array[] = array(gettext("Status"), false, "/freeswitch/freeswitch_status.php"); + $tab_array[] = array(gettext("Vars"), false, "/pkg_edit.php?xml=freeswitch_vars.xml&id=0"); + display_top_tabs($tab_array); + +?> +</td></tr> +</table> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td class="tabcont" > + + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><span class="vexpl"><span class="red"><strong>Dialplan:<br> + </strong></span> + Dialplan Include general settings. + </span></p></td> + </tr> + </table> + <br /> + + <form action="freeswitch_dialplan_includes_edit.php" method="post" name="iform" id="iform"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="22%" valign="top" class="vncellreq">Extension Name</td> + <td width="78%" class="vtable"> + <input name="extensionname" type="text" class="formfld" id="extensionname" size="40" value="<?=htmlspecialchars($pconfig['extensionname']);?>"> + <br /> + Supported characters are 'a-z', 'A-Z', '0-9', underscore '_', and period '.'. + </td> + </tr> + <!-- + <tr> + <td width="22%" valign="top" class="vncellreq">Context</td> + <td width="78%" class="vtable"> + <input name="context" type="text" class="formfld" id="context" size="40" value="<?=htmlspecialchars($pconfig['context']);?>"> + <br /> + e.g. default + </td> + </tr> + --> + + <tr> + <td width="22%" valign="top" class="vncellreq">Enabled</td> + <td width="78%" class="vtable"> + <?php + echo " <select name='enabled' class='formfld'>\n"; + echo " <option></option>\n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + break; + case "false": + echo " <option value='true'>true</option>\n"; + echo " <option value='false' selected='yes'>false</option>\n"; + + break; + default: + echo " <option value='true' selected='yes'>true</option>\n"; + echo " <option value='false'>false</option>\n"; + } + echo " </select>\n"; + ?> + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncellreq">Order</td> + <td width="78%" class="vtable"> + <?php + + echo " <select name='order' class='formfld'>\n"; + echo " <option></option>\n"; + if (strlen(htmlspecialchars($pconfig['order']))> 0) { + echo " <option selected='yes' value='".htmlspecialchars($pconfig['order'])."'>".htmlspecialchars($pconfig['order'])."</option>\n"; + } + $i=0; + while($i<=999) { + if (strlen($i) == 1) { + echo " <option value='00$i'>00$i</option>\n"; + } + if (strlen($i) == 2) { + echo " <option value='0$i'>0$i</option>\n"; + } + if (strlen($i) == 3) { + echo " <option value='$i'>$i</option>\n"; + } + + $i++; + } + echo " </select>\n"; + ?> + <br /> + Processing of each dialplan include is determined by this order. + </td> + </tr> + + <tr> + <td width="22%" valign="top" class="vncell">Description</td> + <td width="78%" class="vtable"> + <input name="descr" type="text" class="formfld" id="descr" size="40" value="<?=htmlspecialchars($pconfig['descr']);?>"> + <br> <span class="vexpl">You may enter a description here + for your reference (not parsed).</span></td> + </tr> + <tr> + <td width="22%" valign="top"> </td> + <td width="78%"> + <input name="dialplanincludeid" type="hidden" value="<?=htmlspecialchars($pconfig['dialplanincludeid']);?>"> + <?php + if (strlen($id) > 0 && $a_dialplan_includes[$id]) { + echo "\n"; + echo " <input name=\"id\" type=\"hidden\" value=\"$id\">\n"; + echo " <input name=\"opt1name\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1name'])."\">\n"; + echo " <input name=\"opt1value\" type=\"hidden\" value=\"".htmlspecialchars($pconfig['opt1value'])."\">\n"; + } + ?> + <input name="Submit" type="submit" class="formbtn" value="Save"> <input class="formbtn" type="button" value="Cancel" onclick="history.back()"> + </td> + </tr> + </table> + </form> + + <br> + <br> + + <form action="freeswitch_dialplan_includes_edit.php" method="post" name="iform2" id="iform2"> + <?php + + //echo "<pre>"; + //print_r ($a_dialplan_includes); + //echo "</pre>"; + + //if ($savemsg) print_info_box($savemsg); + //if (file_exists($d_hostsdirty_path)): echo"<p>"; + //print_info_box_np("The FreeSWITCH recordings have been changed.<br>You must apply the changes in order for them to take effect."); + //echo"<br />"; + //endif; + + ?> + + + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td><p><span class="vexpl"><span class="red"><strong>Conditions and Actions<br /> + </strong></span> + The following conditions, actions and anti-actions are used in the dialplan to direct call flow. Each is processed in order until you reach the action tag which tells FreeSWITCH what action to perform. You are not limited to only one condition or action tag for a given extension. + </span></p></td> + </tr> + </table> + <br /> + + <table width="100%" border="0" cellpadding="0" cellspacing="0"> + <tr> + <td width="20%" class="listhdrr">Tag</td> + <td width="20%" class="listhdrr">Type</td> + <td width="50%" class="listhdrr">Data</td> + <td width="10%" class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + + <?php + + $i = 0; + if (count($a_dialplan_include_details) > 0) { + + foreach ($a_dialplan_include_details as $ent) { + if ($ent['tag'] == "condition" && $dialplanincludeid == $ent['dialplanincludeid']) { + ?> + <tr> + <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'"> + <?=$ent['tag']?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fieldtype'];?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fielddata'];?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + <?php + } + $i++; + } + } + + $i = 0; + if (count($a_dialplan_include_details) > 0) { + + foreach ($a_dialplan_include_details as $ent) { + if ($ent['tag'] == "action" && $dialplanincludeid == $ent['dialplanincludeid']) { + ?> + <tr> + <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'"> + <?=$ent['tag']?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fieldtype'];?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fielddata'];?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + <?php + } + $i++; + } + } + + $i = 0; + if (count($a_dialplan_include_details) > 0) { + + foreach ($a_dialplan_include_details as $ent) { + if ($ent['tag'] == "anti-action" && $dialplanincludeid == $ent['dialplanincludeid']) { + ?> + <tr> + <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'"> + <?=$ent['tag']?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fieldtype'];?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fielddata'];?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + <?php + } + $i++; + } + } + + $i = 0; + if (count($a_dialplan_include_details) > 0) { + + foreach ($a_dialplan_include_details as $ent) { + if ($ent['tag'] == "param" && $dialplanincludeid == $ent['dialplanincludeid']) { + ?> + <tr> + <td class="listlr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>'"> + <?=$ent['tag']?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fieldtype'];?> + </td> + <td class="listr" ondblclick="document.location='freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>';"> + <?=$ent['fielddata'];?> + </td> + <td valign="middle" nowrap class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td> + <td><a href="freeswitch_dialplan_includes_details.php?type=dialplanincludedetails&act=del&id=<?=$i;?>&parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>" onclick="return confirm('Do you really want to delete this?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + <?php + } + $i++; + } + } + ?> + <tr> + <td class="list" colspan="3"></td> + <td class="list"> + <table border="0" cellspacing="0" cellpadding="1"> + <tr> + <td width="17"></td> + <td valign="middle"><a href="freeswitch_dialplan_includes_details_edit.php?parentid=<?=$parentid;?>&dialplanincludeid=<?=$dialplanincludeid;?>&a=action"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td> + </tr> + </table> + </td> + </tr> + + + <tr> + <td class="list" colspan="3"></td> + <td class="list"></td> + </tr> + </table> + + </form> + + + + + <br> + <br> + + </td> + </tr> +</table> + +</div> + +<?php include("fend.inc"); ?> +</body> +</html> |