root/modules/branches/2.1/disa/page.disa.php

Revision 1864, 6.2 kB (checked in by qldrob, 7 years ago)

Added some extra functionality to DISA.. Adjustable timeouts, and a confirmation prompt (useful for callback)

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php /* $Id */
2 //Copyright (C) 2006 Rob Thomas <xrobau@gmail.com>
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of version 2 the GNU General Public
6 //License as published by the Free Software Foundation.
7 //
8 //This program is distributed in the hope that it will be useful,
9 //but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //GNU General Public License for more details.
12
13
14 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
15 $itemid = isset($_REQUEST['itemid'])?$_REQUEST['itemid']:'';
16 $dispnum = "disa"; //used for switch on config.php
17
18 //if submitting form, update database
19 switch ($action) {
20   case "add":
21     disa_add($_POST);
22     needreload();
23   break;
24   case "delete":
25     $oldItem = disa_get($itemid);
26     disa_del($itemid);
27     needreload();
28   break;
29   case "edit":  //just delete and re-add
30     disa_edit($itemid,$_POST);
31     needreload();
32   break;
33 }
34
35
36 $disas = disa_list();
37 ?>
38
39 </div> <!-- end content div so we can display rnav properly-->
40
41 <!-- right side menu -->
42 <div class="rnav">
43     <li><a id="<?php echo ($itemid=='' ? 'current':'std') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add")." DISA" ?></a></li>
44 <?php
45 if (isset($disas)) {
46   foreach ($disas as $d) {
47     echo "<li><a id=\"".($itemid==$d['disa_id'] ? 'current':'std')."\" href=\"config.php?display=".urlencode($dispnum)."&itemid=".urlencode($d['disa_id'])."\">{$d['displayname']} ({$d['disa_id']})</a></li>";
48   }
49 }
50 ?>
51 </div>
52
53 <div class="content">
54 <?php
55 if ($action == 'delete') {
56   echo '<br><h3>DISA '.$oldItem["displayname"].' '._("deleted").'!</h3>';
57 } else {
58   //get details for this time condition
59   $thisItem = disa_get($itemid);
60   $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=delete';
61 ?>
62
63   <h2><?php echo ($itemid ? "DISA: ".$thisItem["displayname"]." ($itemid)" : _("Add")." DISA"); ?></h2>
64 <?php   if ($itemid){ ?>
65   <p><a href="<?php echo $delURL ?>"><?php echo _("Delete")." DISA"?> <?php echo $thisItem["displayname"]; ?></a></p>
66 <?php   } ?>
67   <form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();">
68   <input type="hidden" name="display" value="<?php echo $dispnum?>">
69   <input type="hidden" name="action" value="<?php echo ($itemid ? 'edit' : 'add') ?>">
70   <input type="hidden" name="deptname" value="<?php echo $_SESSION["AMP_user"]->_deptname ?>">
71   <table>
72   <tr><td colspan="2"><h5><?php echo ($itemid ? _("Edit")." DISA" : _("Add")." DISA") ?><hr></h5></td></tr>
73
74   <tr>
75     <td><a href="#" class="info"><?php echo "DISA "._("name:")?><span><?php echo _("Give this DISA a brief name to help you identify it.")?></span></a></td>
76
77     <td><input type="text" name="displayname" value="<?php echo htmlspecialchars(isset($thisItem['displayname']) ? $thisItem['displayname'] : ''); ?>"></td>
78   </tr>
79   <tr>
80     <td><a href="#" class="info"><?php echo _("PIN"); ?><span><?php echo _("The user will be prompted for this number.")." "._("If you wish to have multiple PIN's, seperate them with commas"); ?></span></a></td>
81     <td><input type="text" name="pin" value="<?php echo htmlspecialchars(isset($thisItem['pin']) ? $thisItem['pin'] : ''); ?>"></td>
82   </tr>
83   <tr>
84     <td><a href="#" class="info"><?php echo _("Response Timeout"); ?><span><?php echo _("The maximum amount of time it will wait before hanging up if the user has dialled an incomplete or invalid number. Default of 10 seconds"); ?></span></a></td>
85     <td><input type="text" name="resptimeout" value="<?php echo htmlspecialchars(isset($thisItem['resptimeout']) ? $thisItem['resptimeout'] : '10'); ?>"></td>
86   </tr>
87   <tr>
88     <td><a href="#" class="info"><?php echo _("Digit Timeout"); ?><span><?php echo _("The maximum amount of time permitted between digits when the user is typing in an extension. Default of 5"); ?></span></a></td>
89     <td><input type="text" name="digittimeout" value="<?php echo htmlspecialchars(isset($thisItem['digittimeout']) ? $thisItem['digittimeout'] : '5'); ?>"></td>
90   </tr>
91   <tr>
92     <td><a href="#" class="info"><?php echo _("Require Confirmation"); ?><span><?php echo _("Require Confirmation before prompting for password. Used when your PSTN connection appears to answer the call immediately"); ?></span></a></td>
93     <td><input type="checkbox" name="needconf" value="CHECKED" <?php echo $thisItem['needconf'] ?>  /></td>
94   </tr>
95   <tr>
96     <td><a href="#" class="info"><?php echo _("Caller ID"); ?><span><?php echo _("(Optional) When using this DISA, the users CallerID will be set to this. Format is \"User Name\" <5551234>"); ?></span></a></td>
97     <td><input type="text" name="cid" value="<?php echo htmlspecialchars(isset($thisItem['cid']) ? $thisItem['cid'] : ''); ?>"></td>
98   </tr>
99   <tr>
100     <td><a href="#" class="info"><?php echo _("Context"); ?><span><?php echo _("(Experts Only) Sets the context that calls will originate from. Leave this as from-internal unless you know what you're doing."); ?></span></a></td>
101     <td><input type="text" name="context" value="<?php echo htmlspecialchars(isset($thisItem['context']) ? $thisItem['context'] : 'from-internal'); ?>"></td>
102   </tr>
103         <tr>
104                 <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6></td>
105         </tr>
106         </table>
107
108 <script language="javascript">
109 <!--
110
111 var theForm = document.edit;
112 theForm.displayname.focus();
113
114 function edit_onsubmit() {
115   var msgInvalidDISAName = "<?php echo _('Please enter a valid DISA Name'); ?>";
116   var msgInvalidDISAPIN = "<?php echo _('Please enter a valid DISA PIN'); ?>";
117   var msgInvalidCID = "<?php echo _('Please enter a valid Caller ID or leave it blank'); ?>";
118   var msgInvalidContext = "<?php echo _('Context cannot be blank'); ?>";
119  
120   defaultEmptyOK = false;
121   if (!isAlphanumeric(theForm.displayname.value))
122     return warnInvalid(theForm.displayname, msgInvalidDISAName);
123  
124   defaultEmptyOK = true;
125   if (!isPINList(theForm.pin.value))
126     return warnInvalid(theForm.pin, msgInvalidDISAPIN);
127  
128   defaultEmptyOK = true;
129   if (!isCallerID(theForm.cid.value))
130     return warnInvalid(theForm.cid, msgInvalidCID);
131  
132   defaultEmptyOK = false;
133   if (isEmpty(theForm.context.value))
134     return warnInvalid(theForm.context, msgInvalidContext);
135  
136   return true;
137 }
138
139 //-->
140 </script>
141
142   </form>
143 <?php   
144 }
145 ?>
Note: See TracBrowser for help on using the browser.