root/modules/branches/2.4/core/page.did.php

Revision 7876, 13.3 kB (checked in by p_lindheimer, 3 years ago)

Merged revisions 7875 via svnmerge from
http://svn.freepbx.org/modules/branches/2.5

................

r7874 | p_lindheimer | 2009-06-28 09:04:24 -0700 (Sun, 28 Jun 2009) | 1 line


fixes #3739 add new inbound route direct from URL resulting in proper page loaded

................

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php /* $Id$ */
2 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either version 2
7 //of the License, or (at your option) any later version.
8 //
9 //This program is distributed in the hope that it will be useful,
10 //but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //GNU General Public License for more details.
13
14 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
15 $extdisplay= isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:'';
16 $old_extdisplay = $extdisplay;
17 $dispnum = 'did'; //used for switch on config.php
18 $account = isset($_REQUEST['account'])?$_REQUEST['account']:'';
19 $goto = isset($_REQUEST['goto0'])?$_REQUEST['goto0']:'';
20 $ringing = isset($_REQUEST['ringing'])?$_REQUEST['ringing']:'';
21 $description = isset($_REQUEST['description'])?$_REQUEST['description']:'';
22
23 if (isset($_REQUEST['extension']) && isset($_REQUEST['cidnum'])) {
24   $extdisplay = $_REQUEST['extension']."/".$_REQUEST['cidnum'];
25 }
26
27 //update db if submiting form
28 switch ($action) {
29   case 'addIncoming':
30     //create variables from request
31     extract($_REQUEST);
32     //add details to the 'incoming' table
33     if (core_did_add($_REQUEST)) {
34       needreload();
35       redirect_standard('extdisplay', 'extension', 'cidnum');
36     }
37   break;
38   case 'delIncoming':
39     $extarray=explode('/',$extdisplay,2);
40     core_did_del($extarray[0],$extarray[1]);
41     needreload();
42     redirect_standard();
43   break;
44   case 'edtIncoming':
45     $extarray=explode('/',$old_extdisplay,2);
46     if (core_did_edit($extarray[0],$extarray[1],$_REQUEST)) {
47       needreload();
48       redirect_standard('extdisplay', 'extension', 'cidnum');
49     }
50   break;
51 }
52
53 ?>
54 </div>
55
56 <div class="rnav">
57 <ul>
58   <li><a <?php echo ($extdisplay=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Incoming Route")?></a></li>
59 <?php 
60 //get unique incoming routes
61 $inroutes = core_did_list('description');
62 if (isset($inroutes)) {
63   foreach ($inroutes as $inroute) {
64     $displaydid = ( empty($inroute['extension'])? _("any DID") : $inroute['extension'] );
65     $displaycid = ( empty($inroute['cidnum'])? _("any CID") : $inroute['cidnum'] );
66     $desc = ( empty($inroute['description'])? "" : $inroute['description']."<br />" );
67     echo "\t<li><a ".($extdisplay==$inroute['extension']."/".$inroute['cidnum'] ? 'class="current"':'')." href=\"config.php?display=".urlencode($dispnum)."&amp;extdisplay=".urlencode($inroute['extension'])."/".urlencode($inroute['cidnum'])."\">{$desc} {$displaydid} / {$displaycid} </a></li>\n";
68   }
69 }
70 ?>
71 </ul>
72 </div>
73
74 <div class="content">
75 <?php 
76   if ($action == 'delIncoming') {
77     echo '<br><h3>Route '.$extdisplay.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
78   } else {
79     if ($extdisplay) {
80       //create variables for the selected route's settings
81       $extarray=explode('/',$extdisplay,2);
82       $ininfo=core_did_get($extarray[0],$extarray[1]);
83       if (is_array($ininfo) && !empty($ininfo)) {
84         extract($ininfo);
85         $delete_url = true;
86 ?>
87     <h2><?php echo _("Route")?>: <?php echo !empty($description)?$description:$extdisplay; ?></h2>
88 <?php
89       } else {
90         $extension = $extarray[0];
91         $cidnum    = $extarray[1];
92         $delete_url = false;
93         $extdisplay = '';
94 ?>
95     <h2><?php echo _("Add Incoming Route")?></h2>
96 <?php
97       }
98       if ($delete_url) {
99         $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=delIncoming';
100 ?>
101     <a href="<?php echo $delURL ?>"><?php echo _("Delete Route")?> <?php echo !empty($description)?$description:$extdisplay ?></a>
102 <?php 
103       }
104     } else { ?>
105     <h2><?php echo _("Add Incoming Route")?></h2>
106 <?php 
107 } 
108 ?>
109     <form name="editGRP" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return editGRP_onsubmit();">
110     <input type="hidden" name="display" value="<?php echo $dispnum?>">
111     <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edtIncoming' : 'addIncoming') ?>">
112     <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>">
113     <table>
114     <tr><td colspan="2"><h5><?php echo ($extdisplay ? _('Edit Incoming Route') : _('Add Incoming Route')) ?><hr></h5></td></tr>
115     <tr>
116       <td><a href="#" class="info"><?php echo _("Description")?><span><?php echo _('Provide a meaningful description of what this incoming route is')?></span></a>:</td>
117       <td><input type="text" name="description" value="<?php echo htmlspecialchars(isset($description)?$description:''); ?>"></td>
118     </tr>
119     <tr>
120       <td><a href="#" class="info"><?php echo _("DID Number")?><span><?php echo _('Define the expected DID Number if your trunk passes DID on incoming calls. <br><br>Leave this blank to match calls with any or no DID info.<br><br>You can also use a pattern match (eg _2[345]X) to match a range of numbers')?></span></a>:</td>
121       <td><input type="text" name="extension" value="<?php echo htmlspecialchars(isset($extension)?$extension:''); ?>"></td>
122     </tr>
123     <tr>
124       <td><a href="#" class="info"><?php echo _("Caller ID Number")?><span><?php echo _('Define the Caller ID Number to be matched on incoming calls.<br><br>Leave this field blank to match any or no CID info.')?></span></a>:</td>
125       <td><input type="text" name="cidnum" value="<?php echo htmlspecialchars(isset($cidnum)?$cidnum:'') ?>"></td>
126     </tr>
127     <tr><td colspan="2"><h5><?php echo _("Fax Handling")?><hr></h5></td></tr>
128     <tr>
129       <td>
130         <a class="info" href="#"><?php echo _("Fax Extension")?><span><?php echo _("Select 'system' to have the system receive and email faxes.<br><br>The FreePBX default is defined in General Settings.")?></span></a>:
131       </td>
132       <td>
133         <select name="faxexten">
134 <?php 
135 // Cleaning up warnings. I should do this a better way.
136 if (!isset($faxexten))
137   $faxexten = null;
138 if (!isset($faxemail))
139   $faxemail = null;
140 if (!isset($answer))
141   $answer = '0';
142 if (!isset($alertinfo))
143   $alertinfo = 0;
144 if (!isset($mohclass))
145   $mohclass = 'default';
146 if (!isset($grppre))
147   $grppre = "";
148 ?>
149           <option value="default" <?php  echo ($faxexten == 'default' ? 'SELECTED' : '')?>><?php echo _("FreePBX default")?>
150           <option value="disabled" <?php  echo ($faxexten == 'disabled' ? 'SELECTED' : '')?>><?php echo _("disabled")?>
151           <option value="system" <?php  echo ($faxexten == 'system' ? 'SELECTED' : '')?>><?php echo _("system")?>
152       <?php
153         //get unique devices
154         $devices = core_devices_list();
155         if (isset($devices)) {
156           foreach ($devices as $device) {
157             echo '<option value="'.$device[0].'" '.($faxexten == $device[0] ? 'SELECTED' : '').'>'.$device[1].' &lt;'.$device[0].'&gt;';
158           }
159         }
160       ?> 
161         </select>
162       </td>
163     </tr>
164     <tr>
165       <td>
166         <a class="info" href="#"><?php echo _("Fax Email")?><span><?php echo _("Email address is used if 'system' has been chosen for the fax extension above.<br><br>Leave this blank to use the FreePBX default in General Settings.")?></span></a>:
167       </td>
168       <td>
169         <input type="text" size="20" name="faxemail" value="<?php echo htmlspecialchars($faxemail)?>"/>
170       </td>
171     </tr>
172     <tr>
173       <td><a href="#" class="info"><?php echo _("Fax Detection Type")?><span><?php echo _('Selecting Zaptel or NVFax will immediately answer the call and play ringing tones to the caller for the number of seconds in Pause below. Use NVFax on SIP or IAX trunks.')?></span></a>:</td>
174       <td>
175         <select name="answer">
176           <option value="0" <?php  echo ($answer == '0' ? 'SELECTED' : '')?>><?php echo _("None")?>
177           <option value="1" <?php  echo ($answer == '1' ? 'SELECTED' : '')?>><?php echo _("Zaptel")?>
178           <option value="2" <?php  echo ($answer == '2' ? 'SELECTED' : '')?>><?php echo _("NVFax")?>
179         </select>
180       </td>
181     </tr>
182     <tr>
183       <td><a href="#" class="info"><?php echo _("Pause After Answer")?><span><?php echo _('The number of seconds we should wait after performing an Immediate Answer. The primary purpose of this is to pause and listen for a fax tone before allowing the call to proceed.')?></span></a>:</td>
184       <td><input type="text" name="wait" size="3" value="<?php echo isset($wait)?$wait:'' ?>"></td>
185     </tr>
186 <?php
187 if (!isset($privacyman))
188   $privacyman = '0';
189 ?>
190
191     <tr><td colspan="2"><h5><?php echo _("Privacy")?><hr></h5></td></tr>
192     <tr>
193       <td><a href="#" class="info"><?php echo _("Privacy Manager")?><span><?php echo _('If no Caller ID is sent, Privacy Manager will asks the caller to enter their 10 digit phone number. The caller is given 3 attempts.')?></span></a>:</td>
194       <td>
195         <select name="privacyman">
196           <option value="0" <?php  echo ($privacyman == '0' ? 'SELECTED' : '')?>><?php echo _("No")?>
197           <option value="1" <?php  echo ($privacyman == '1' ? 'SELECTED' : '')?>><?php echo _("Yes")?>
198         </select>
199       </td>
200     </tr>
201     
202     <tr><td colspan="2"><h5><?php echo _("Options")?><hr></h5></td></tr>
203     <tr>
204       <td><a href="#" class="info"><?php echo _("Alert Info")?><span><?php echo _('ALERT_INFO can be used for distinctive ring with SIP devices.')?></span></a>:</td>
205       <td><input type="text" name="alertinfo" size="10" value="<?php echo ($alertinfo)?$alertinfo:'' ?>"></td>
206     </tr>
207     <tr>
208       <td><a href="#" class="info"><?php echo _("CID name prefix")?>:<span><?php echo _('You can optionally prefix the Caller ID name. ie: If you prefix with "Sales:", a call from John Doe would display as "Sales:John Doe" on the extensions that ring.')?></span></a>:</td>
209       <td><input type="text" name="grppre" size="10" value="<?php echo ($grppre)?$grppre:'' ?>"></td>
210     </tr>
211 <?php   if (function_exists('music_list')) { ?>
212     <tr>
213       <td><a href="#" class="info"><?php echo _("Music On Hold?")?><span><?php echo _("Set the MoH class that will be used for calls that come in on this route. For example, choose a type appropriate for routes coming in from a country which may have announcements in their language.")?></span></a></td>
214       <td>
215         <select name="mohclass">
216         <?php
217           $tresults = music_list($amp_conf['ASTVARLIBDIR']."/mohmp3");
218           $cur = (isset($mohclass) && $mohclass != "" ? $mohclass : 'default');
219           echo '<option value="none">'._("No Music")."</option>";
220           if (isset($tresults[0])) {
221             foreach ($tresults as $tresult) {
222               echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$tresult."</option>\n";
223             }
224           }
225         ?>   
226         </select>   
227       </td>
228     </tr>
229 <?php } ?>
230     <tr>
231       <td><a href="#" class="info"><?php echo _("Signal RINGING")?><span><?php echo _('Some devices or providers require RINGING to be sent before ANSWER. You\'ll notice this happening if you can send calls directly to a phone, but if you send it to an IVR, it won\'t connect the call.')?></span></a>:</td>
232       <td><input type="checkbox" name="ringing" value="CHECKED" <?php echo $ringing ?> /></td>
233     </tr>
234 <?php
235   // implementation of module hook
236   // object was initialized in config.php
237   echo $module_hook->hookHtml;
238 ?>
239     <tr><td colspan="2"><h5><?php echo _("Set Destination")?><hr></h5></td></tr>
240 <?php 
241 //draw goto selects
242 echo drawselects(isset($destination)?$destination:null,0);
243 ?>
244     <tr>
245       <td colspan="2">
246         <h6><input name="Submit" type="submit" value="<?php echo _("Submit")?>"></h6>
247       </td>   
248     </tr>
249     </table>
250 <script language="javascript">
251 <!--
252
253 var theForm = document.editGRP;
254
255 theForm.extension.focus();
256
257 function editGRP_onsubmit() {
258   var msgInvalidDIDNumb = "<?php echo _('Please enter a valid DID Number'); ?>";
259   var msgInvalidCIDNum = "<?php echo _('Please enter a valid Caller ID Number'); ?>";
260   var msgInvalidFaxEmail = "<?php echo _('Please enter a valid Fax Email or leave it empty to use the default'); ?>";
261   var msgInvalidPause = "<?php echo _('Please enter a valid number for Pause after answer'); ?>";
262   var msgConfirmDIDCIDBlank = "<?php echo _('Leaving the DID Number AND the Caller ID Number empty will match all incoming calls received not routed using any other defined Incoming Route.\n\nAre you sure?'); ?>";
263   var msgConfirmDIDNonStd = "<?php echo _('DID information is normally just an incoming telephone number or for advanced users, a valid Asterisk Dial Pattern\n\nYou have entered a non standard DID pattern.\n\nAre you sure this is correct?'); ?>";
264   var msgConfirmDIDNoSlash = "<?php echo _('A Slash (\'/\') is never a valid DID. Please remove it and try again'); ?>";
265   var msgInvalidGrpPrefix = "<?php echo _('Invalid Caller ID prefix.'); ?>";
266  
267   setDestinations(theForm,1);
268  
269   defaultEmptyOK = true;
270   if (!isDialpattern(theForm.extension.value)) {
271     // warn the user that DID is normally numbers
272     if (!confirm(msgConfirmDIDNonStd))
273       return false;
274   }
275  
276   if (isInside(theForm.extension.value, "/")) {
277     warnInvalid(theForm.extension, msgConfirmDIDNoSlash);
278     return false;
279   }
280   if (!isDialpattern(theForm.cidnum.value))
281     return warnInvalid(theForm.cidnum, msgInvalidCIDNum);
282  
283   if (!isEmail(theForm.faxemail.value))
284     return warnInvalid(theForm.faxemail, msgInvalidFaxEmail);
285  
286   if (!isInteger(theForm.wait.value))
287     return warnInvalid(theForm.wait, msgInvalidPause);
288  
289   if (!validateDestinations(theForm,1,true))
290     return false;
291  
292   // warning about 'any DID / any CID'
293   if (theForm.extension.value == "" && theForm.cidnum.value == "" && theForm.channel.value == "" ) {
294     if (!confirm(msgConfirmDIDCIDBlank))
295       return false;
296   }
297   defaultEmptyOK = true;
298   if (!isCallerID(theForm.grppre.value))
299     return warnInvalid(theForm.grppre, msgInvalidGrpPrefix);
300  
301   return true;
302 }
303
304 //-->
305 </script>
306     </form>
307 <?php    
308   } //end if action == delGRP
309
310 ?>
Note: See TracBrowser for help on using the browser.