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

Revision 6049, 16.6 kB (checked in by p_lindheimer, 5 years ago)

#2923 add back the Call Screening option that were lost when the directdid + inbound routes were merged

  • 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 if (isset($_REQUEST['submitclear'])) {
23     $_REQUEST[$goto0.'0'] = '';
24 }
25
26 if (isset($_REQUEST['extension']) && isset($_REQUEST['cidnum'])) {
27     $extdisplay = $_REQUEST['extension']."/".$_REQUEST['cidnum'];
28 }
29
30 $didfilter = isset($_REQUEST['didfilter'])?$_REQUEST['didfilter']:'';
31
32 //update db if submiting form
33 switch ($action) {
34     case 'addIncoming':
35         //create variables from request
36         extract($_REQUEST);
37         //add details to the 'incoming' table
38         if (core_did_add($_REQUEST)) {
39             needreload();
40             redirect_standard('extdisplay', 'extension', 'cidnum');
41         }
42     break;
43     case 'delIncoming':
44         $extarray=explode('/',$extdisplay,2);
45         core_did_del($extarray[0],$extarray[1]);
46         needreload();
47         redirect_standard();
48     break;
49     case 'edtIncoming':
50         $extarray=explode('/',$old_extdisplay,2);
51         if (core_did_edit($extarray[0],$extarray[1],$_REQUEST)) {
52             needreload();
53             redirect_standard('extdisplay', 'extension', 'cidnum');
54         }
55     break;
56 }
57
58 ?>
59 </div>
60
61 <?php
62 $display_link = isset($extdisplay) && $extdisplay != '' ? "&amp;extdisplay=".$extdisplay : '';
63 ?>
64 <div class="rnav">
65 <ul>
66     <li><a <?php echo ($extdisplay=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Incoming Route")?></a></li>
67     <li><a <?php echo ($didfilter=='' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).$display_link?>"><?php echo _("View All DIDs")?></a></li>
68     <li><a <?php echo ($didfilter=='directdid' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&amp;didfilter=directdid'.$display_link?>"><?php echo _("View User DIDs")?></a></li>
69     <li><a <?php echo ($didfilter=='incoming' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&amp;didfilter=incoming'.$display_link?>"><?php echo _("View General DIDs")?></a></li>
70     <li><a <?php echo ($didfilter=='unassigned' ? 'class="current"':'') ?> href="config.php?display=<?php echo urlencode($dispnum).'&amp;didfilter=unassigned'.$display_link?>"><?php echo _("View Unused DIDs")?></a></li><hr>
71 <?php
72 //get unique incoming routes
73 $inroutes = core_did_list('description');
74 switch ($didfilter) {
75     case 'directdid':
76         foreach ($inroutes as $key => $did_items) {
77             $did_dest = split(',',$did_items['destination']);
78             if (!isset($did_dest[0]) || $did_dest[0] != 'from-did-direct') {
79                 unset($inroutes[$key]);
80             }
81         }
82         break;
83     case 'incoming':
84         foreach ($inroutes as $key => $did_items) {
85             $did_dest = split(',',$did_items['destination']);
86             if (!isset($did_dest[0]) || $did_dest[0] == 'from-did-direct') {
87                 unset($inroutes[$key]);
88             }
89         }
90         break;
91     case 'unassigned':
92         foreach ($inroutes as $key => $did_items) {
93             if (isset($did_items['destination']) && $did_items['destination'] != '') {
94                 unset($inroutes[$key]);
95             }
96         }
97         break;
98     default:
99 }
100 if (isset($inroutes)) {
101     foreach ($inroutes as $inroute) {
102         $displaydid = ( empty($inroute['extension'])? _("any DID") : $inroute['extension'] );
103          $displaycid = ( empty($inroute['cidnum'])? _("any CID") : $inroute['cidnum'] );
104         $desc = ( empty($inroute['description'])? "" : $inroute['description']."<br />" );
105         echo "\t<li><a ".($extdisplay==$inroute['extension']."/".$inroute['cidnum'] ? 'class="current"':'')." href=\"config.php?display=".urlencode($dispnum)."&amp;didfilter=$didfilter&amp;extdisplay=".urlencode($inroute['extension'])."/".urlencode($inroute['cidnum'])."\">{$desc} {$displaydid} / {$displaycid} </a></li>\n";
106     }
107 }
108 ?>
109 </ul>
110 </div>
111
112 <div class="content">
113 <?php
114     if ($action == 'delIncoming') {
115         echo '<br><h3>Route '.$extdisplay.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
116     } else {
117 ?>
118 <?php
119         if ($extdisplay) {   
120         //create variables for the selected route's settings
121         $extarray=explode('/',$extdisplay,2);
122         $ininfo=core_did_get($extarray[0],$extarray[1]);
123         if (is_array($ininfo)) {
124              extract($ininfo);
125         }
126 ?>
127         <h2><?php echo _("Route")?>: <?php echo !empty($description)?$description:$extdisplay; ?></h2>
128 <?php
129         $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=delIncoming';
130         $tlabel = sprintf(_("Delete Route %s"),!empty($description)?$description:$extdisplay);
131         $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/core_delete.png"/>&nbsp;'.$tlabel.'</span>';
132         echo "<p><a href=".$delURL.">".$label."</a></p>";
133         // If this is a direct did, e.g. from-did-direct,nnn,1 then make a link to the extension
134         //
135         $did_dest = split(',',$destination);
136         if (isset($did_dest[0]) && $did_dest[0] == 'from-did-direct') {
137
138             if (isset($amp_conf["AMPEXTENSIONS"]) && ($amp_conf["AMPEXTENSIONS"] == "deviceanduser")) {
139                 $editURL = $_SERVER['PHP_SELF'].'?display=users&extdisplay='.$did_dest[1];
140                 $EXTorUSER = _("User");
141             }
142             else {
143                 $editURL = $_SERVER['PHP_SELF'].'?display=extensions&extdisplay='.$did_dest[1];
144                 $EXTorUSER = _("Extension");
145             }
146             $label = '<span><img width="16" height="16" border="0" title="'.sprintf(_("Edit %s"),$EXTorUSER).'" alt="" src="images/user_edit.png"/>&nbsp;'.sprintf(_("Edit %s %s"),$EXTorUSER, $did_dest[1]).'</span>';
147             echo "<p><a href=".$editURL.">".$label."</a></p>";
148         }
149 ?>
150 <?php
151     } else {
152 ?>
153             <h2><?php echo _("Add Incoming Route")?></h2>
154 <?php
155     }
156 ?>
157         <form name="editGRP" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return editGRP_onsubmit();">
158         <input type="hidden" name="display" value="<?php echo $dispnum?>">
159         <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edtIncoming' : 'addIncoming') ?>">
160         <input type="hidden" name="extdisplay" value="<?php echo $extdisplay ?>">
161         <table>
162         <tr><td colspan="2"><h5><?php echo ($extdisplay ? _('Edit Incoming Route') : _('Add Incoming Route')) ?><hr></h5></td></tr>
163         <tr>
164             <td><a href="#" class="info"><?php echo _("Description")?><span><?php echo _('Provide a meaningful description of what this incoming route is')?></span></a>:</td>
165             <td><input type="text" name="description" value="<?php echo htmlspecialchars(isset($description)?$description:''); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
166         </tr>
167         <tr>
168             <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>
169             <td><input type="text" name="extension" value="<?php echo htmlspecialchars(isset($extension)?$extension:''); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
170         </tr>
171         <tr>
172             <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>
173             <td><input type="text" name="cidnum" value="<?php echo htmlspecialchars(isset($cidnum)?$cidnum:'') ?>" tabindex="<?php echo ++$tabindex;?>"></td>
174         </tr>
175         <tr><td colspan="2"><h5><?php echo _("Fax Handling")?><hr></h5></td></tr>
176         <tr>
177             <td>
178                 <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>:
179             </td>
180             <td>
181                 <select name="faxexten" tabindex="<?php echo ++$tabindex;?>">
182 <?php
183 // Cleaning up warnings. I should do this a better way.
184 if (!isset($faxexten))
185     $faxexten = null;
186 if (!isset($faxemail))
187     $faxemail = null;
188 if (!isset($answer))
189     $answer = '0';
190 if (!isset($alertinfo))
191     $alertinfo = 0;
192 if (!isset($mohclass))
193     $mohclass = 'default';
194 if (!isset($grppre))
195     $grppre = "";
196 ?>
197                     <option value="default" <?php  echo ($faxexten == 'default' ? 'SELECTED' : '')?>><?php echo _("FreePBX default")?>
198                     <option value="disabled" <?php  echo ($faxexten == 'disabled' ? 'SELECTED' : '')?>><?php echo _("disabled")?>
199                     <option value="system" <?php  echo ($faxexten == 'system' ? 'SELECTED' : '')?>><?php echo _("system")?>
200             <?php
201                 //get unique devices
202                 $devices = core_devices_list();
203                 if (isset($devices)) {
204                     foreach ($devices as $device) {
205                         echo '<option value="'.$device[0].'" '.($faxexten == $device[0] ? 'SELECTED' : '').'>'.$device[1].' &lt;'.$device[0].'&gt;';
206                     }
207                 }
208             ?>   
209                 </select>
210             </td>
211         </tr>
212         <tr>
213             <td>
214                 <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>:
215             </td>
216             <td>
217                 <input type="text" size="20" name="faxemail" value="<?php echo htmlspecialchars($faxemail)?>" tabindex="<?php echo ++$tabindex;?>"/>
218             </td>
219         </tr>
220         <tr>
221             <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>
222             <td>
223                 <select name="answer" tabindex="<?php echo ++$tabindex;?>">
224                     <option value="0" <?php  echo ($answer == '0' ? 'SELECTED' : '')?>><?php echo _("None")?>
225                     <option value="1" <?php  echo ($answer == '1' ? 'SELECTED' : '')?>><?php echo _("Zaptel")?>
226                     <option value="2" <?php  echo ($answer == '2' ? 'SELECTED' : '')?>><?php echo _("NVFax")?>
227                 </select>
228             </td>
229         </tr>
230         <tr>
231             <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>
232             <td><input type="text" name="wait" size="3" value="<?php echo isset($wait)?$wait:'' ?>" tabindex="<?php echo ++$tabindex;?>"></td>
233         </tr>
234 <?php
235 if (!isset($privacyman))
236     $privacyman = '0';
237 ?>
238
239         <tr><td colspan="2"><h5><?php echo _("Privacy")?><hr></h5></td></tr>
240         <tr>
241             <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. The number of digits and attempts can be defined in privacy.conf. If a user has Call Screening enabled, the incoming caller will be asked to enter their CallerId here if enabled, and then to say their name once determined that the called user requires it.')?></span></a>:</td>
242             <td>
243                 <select name="privacyman" tabindex="<?php echo ++$tabindex;?>">
244                     <option value="0" <?php  echo ($privacyman == '0' ? 'SELECTED' : '')?>><?php echo _("No")?>
245                     <option value="1" <?php  echo ($privacyman == '1' ? 'SELECTED' : '')?>><?php echo _("Yes")?>
246                 </select>
247             </td>
248         </tr>
249        
250         <tr><td colspan="2"><h5><?php echo _("Options")?><hr></h5></td></tr>
251         <tr>
252             <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>
253             <td><input type="text" name="alertinfo" size="10" value="<?php echo ($alertinfo)?$alertinfo:'' ?>" tabindex="<?php echo ++$tabindex;?>"></td>
254         </tr>
255         <tr>
256             <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>
257             <td><input type="text" name="grppre" size="10" value="<?php echo ($grppre)?$grppre:'' ?>" tabindex="<?php echo ++$tabindex;?>"></td>
258         </tr>
259 <?php   if (function_exists('music_list')) { ?>
260         <tr>
261             <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>
262             <td>
263                 <select name="mohclass" tabindex="<?php echo ++$tabindex;?>">
264                 <?php
265                     $tresults = music_list($amp_conf['ASTVARLIBDIR']."/mohmp3");
266                     $cur = (isset($mohclass) && $mohclass != "" ? $mohclass : 'default');
267                     echo '<option value="none">'._("No Music")."</option>";
268                     if (isset($tresults[0])) {
269                         foreach ($tresults as $tresult) {
270                             echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$tresult."</option>\n";
271                         }
272                     }
273                 ?>       
274                 </select>       
275             </td>
276         </tr>
277 <?php } ?>
278         <tr>
279             <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>
280             <td><input type="checkbox" name="ringing" value="CHECKED" <?php echo $ringing ?>  tabindex="<?php echo ++$tabindex;?>"/></td>
281         </tr>
282 <?php
283     // implementation of module hook
284     // object was initialized in config.php
285     echo $module_hook->hookHtml;
286 ?>
287         <tr><td colspan="2"><h5><?php echo _("Set Destination")?><hr></h5></td></tr>
288
289 <?php
290     if ($extdisplay) {   
291 ?>
292         <tr><td colspan="2"><a href="<?php echo $clrdestURL ?>"><?php echo _("Clear Destination")?></a><br /><br /></td></tr>
293 <?php
294     }
295 //draw goto selects
296 echo drawselects(isset($destination)?$destination:null,0);
297 ?>
298         <tr>
299             <td colspan="2">
300                 <h6><input name="Submit" type="submit" value="<?php echo _("Submit")?>" tabindex="<?php echo ++$tabindex;?>">&nbsp;&nbsp;
301                 <input name="submitclear" type="submit" value="<?php echo _("Clear Destination & Submit")?>" ></h6>
302             </td>       
303         </tr>
304         </table>
305 <script language="javascript">
306 <!--
307
308 var theForm = document.editGRP;
309
310 theForm.extension.focus();
311
312 function editGRP_onsubmit() {
313     var msgInvalidDIDNumb = "<?php echo _('Please enter a valid DID Number'); ?>";
314     var msgInvalidCIDNum = "<?php echo _('Please enter a valid Caller ID Number'); ?>";
315     var msgInvalidFaxEmail = "<?php echo _('Please enter a valid Fax Email or leave it empty to use the default'); ?>";
316     var msgInvalidPause = "<?php echo _('Please enter a valid number for Pause after answer'); ?>";
317     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?'); ?>";
318     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?'); ?>";
319     var msgConfirmDIDNoSlash = "<?php echo _('A Slash (\'/\') is never a valid DID. Please remove it and try again'); ?>";
320     var msgInvalidGrpPrefix = "<?php echo _('Invalid Caller ID prefix.'); ?>";
321    
322     setDestinations(theForm,1);
323    
324     defaultEmptyOK = true;
325     if (!isDialpattern(theForm.extension.value)) {
326         // warn the user that DID is normally numbers
327         if (!confirm(msgConfirmDIDNonStd))
328             return false;
329     }
330    
331     if (isInside(theForm.extension.value, "/")) {
332         warnInvalid(theForm.extension, msgConfirmDIDNoSlash);
333         return false;
334     }
335     if (!isDialpattern(theForm.cidnum.value))
336         return warnInvalid(theForm.cidnum, msgInvalidCIDNum);
337    
338     if (!isEmail(theForm.faxemail.value))
339         return warnInvalid(theForm.faxemail, msgInvalidFaxEmail);
340    
341     if (!isInteger(theForm.wait.value))
342         return warnInvalid(theForm.wait, msgInvalidPause);
343    
344     if (!validateDestinations(theForm,1,true))
345         return false;
346    
347     // warning about 'any DID / any CID'
348     if (theForm.extension.value == "" && theForm.cidnum.value == "" && theForm.channel.value == "" ) {
349         if (!confirm(msgConfirmDIDCIDBlank))
350             return false;
351     }
352     defaultEmptyOK = true;
353     if (!isCallerID(theForm.grppre.value))
354         return warnInvalid(theForm.grppre, msgInvalidGrpPrefix);
355    
356     return true;
357 }
358
359 //-->
360 </script>
361         </form>
362 <?php         
363     } //end if action == delGRP
364
365 ?>
366
Note: See TracBrowser for help on using the browser.