Ticket #3549: sipiaxchandid.patch
| File sipiaxchandid.patch, 11.6 kB (added by Nick_Lewis, 3 years ago) |
|---|
-
old/functions.inc.php
old new 1009 1009 1010 1010 } 1011 1011 1012 // Now create macro-from- zaptel-nnn for each defined channel to route it to the DID routing1012 // Now create macro-from-channel-nnn for each defined channel to route it to the DID routing 1013 1013 // Send it to from-trunk so it is handled as other dids would be handled. 1014 1014 // 1015 1015 foreach (core_zapchandids_list() as $row) { 1016 1016 $channel = $row['channel']; 1017 1017 $did = $row['did']; 1018 1018 1019 $zap_context = "macro-from-zaptel-{$channel}"; 1020 $ext->add($zap_context, 's', '', new ext_noop('Entering '.$zap_context.' with DID = ${DID} and setting to: '.$did)); 1021 $ext->add($zap_context, 's', '', new ext_setvar('__FROM_DID',$did)); 1022 $ext->add($zap_context, 's', '', new ext_goto('1',$did,'from-trunk')); 1019 $channel_context = "macro-from-channel-{$channel}"; 1020 1021 //magic string 'siptoheader' for extracting DID from sip To: header 1022 if ($did == "siptoheader") { 1023 $ext->add($channel_context, 's', '', new ext_noop('Entering '.$channel_context.' with DID = ${DID}')); 1024 $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID','${SIP_HEADER(TO)}')); 1025 $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID','${CUT(FROM_DID,@,1)}')); 1026 $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID','${CUT(FROM_DID,:,2)}')); 1027 $ext->add($channel_context, 's', '', new ext_noop('Used sip To: header to set DID = ${FROM_DID}')); 1028 $ext->add($channel_context, 's', '', new ext_goto('1','${FROM_DID}','from-trunk')); 1029 } else { 1030 $ext->add($channel_context, 's', '', new ext_noop('Entering '.$channel_context.' with DID = ${DID} and setting to: '.$did)); 1031 $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID',$did)); 1032 $ext->add($channel_context, 's', '', new ext_goto('1',$did,'from-trunk')); 1033 } 1023 1034 } 1024 1035 1025 1036 /* user extensions */ … … 1134 1145 case 'IAX2': 1135 1146 case 'SIP': 1136 1147 $trunkgroup = $trunkprops['globalvar']; 1137 $trunkcontext = "from-trunk-".strtolower($trunkprops['tech'])."-".$trunkprops['name']; 1138 $ext->add($trunkcontext, '_.', '', new ext_setvar('GROUP()',$trunkgroup)); 1139 $ext->add($trunkcontext, '_.', '', new ext_goto('1','${EXTEN}','from-trunk')); 1148 $context = "from-trunk-".strtolower($trunkprops['tech'])."-".$trunkprops['name']; 1149 $channeltech = $trunkprops['tech']; 1150 //if ($channeltech == "IAX2") {$channeltech = "IAX";} 1151 1152 $exten = '_.'; 1153 1154 $ext->add($context, $exten, '', new ext_set('DID', '${EXTEN}')); 1155 $ext->add($context, $exten, '', new ext_goto(1, 's')); 1156 1157 $exten = 's'; 1158 $ext->add($context, $exten, '', new ext_noop('Entering '.$context.' with DID == ${DID}')); 1159 $ext->add($context, $exten, '', new ext_setvar('GROUP()',$trunkgroup)); 1160 // Some trunks _require_ a RINGING be sent before an Answer. 1161 $ext->add($context, $exten, '', new ext_ringing()); 1162 // If ($did == "") { $did = "s"; } 1163 $ext->add($context, $exten, '', new ext_set('DID', '${IF($["${DID}"= ""]?s:${DID})}')); 1164 $ext->add($context, $exten, '', new ext_noop('DID is now ${DID}')); 1165 $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:3}"="'.$channeltech.'"]', 'trunkok', 'nottrunk')); 1166 $ext->add($context, $exten, 'nottrunk', new ext_goto('1', '${DID}', 'from-trunk')); 1167 // If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup. 1168 $ext->add($context, $exten, '', new ext_macro('Hangupcall', 'dummy')); 1169 $ext->add($context, $exten, 'trunkok', new ext_noop('Is a '.$channeltech.' Trunk Channel')); 1170 $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:4}')); 1171 $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); 1172 $ext->add($context, $exten, '', new ext_macro('from-channel-${CHAN}', '${DID},1')); 1173 // If nothing there, then treat it as a DID 1174 $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-channel-${CHAN}')); 1175 $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-trunk')); 1176 1177 1140 1178 break; 1141 1179 default: 1142 1180 } … … 1874 1912 $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:4}')); 1875 1913 } 1876 1914 $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); 1877 $ext->add($context, $exten, '', new ext_macro('from- zaptel-${CHAN}', '${DID},1'));1915 $ext->add($context, $exten, '', new ext_macro('from-channel-${CHAN}', '${DID},1')); 1878 1916 // If nothing there, then treat it as a DID 1879 $ext->add($context, $exten, '', new ext_noop('Returned from Macro from- zaptel-${CHAN}'));1917 $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-channel-${CHAN}')); 1880 1918 $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-pstn')); 1881 1919 $ext->add($context, 'fax', '', new ext_goto(1, 'in_fax', 'ext-fax')); 1882 1920 … … 3041 3079 global $db; 3042 3080 3043 3081 3044 if ( !ctype_digit(trim($channel)) ||trim($channel) == '') {3045 echo "<script>javascript:alert('"._("Invalid Channel Number, must be numeric and notblank")."')</script>";3082 if (trim($channel) == '') { 3083 echo "<script>javascript:alert('"._("Invalid Channel Number, must not be blank")."')</script>"; 3046 3084 return false; 3047 3085 } 3048 3086 if (trim($did) == '') { … … 3050 3088 return false; 3051 3089 } 3052 3090 3091 //permit non numeric channel names 3092 if (!is_numeric($channel)) { 3093 $tableinfo = $db->tableinfo('zapchandids'); 3094 if ($tableinfo[0]['type'] != 'string') { 3095 $sql = "ALTER TABLE zapchandids CHANGE COLUMN channel channel VARCHAR(40)"; 3096 $results = $db->query($sql); 3097 if (DB::IsError($results)) {die_freepbx($results->getMessage()."<br><br>".$sql);} 3098 } 3099 } 3100 3053 3101 $description = q($description); 3054 3102 $channel = q($channel); 3055 3103 $did = q($did); … … 3070 3118 function core_zapchandids_edit($description, $channel, $did) { 3071 3119 global $db; 3072 3120 3121 //permit non numeric channel names 3122 if (!is_numeric($channel)) { 3123 $tableinfo = $db->tableinfo('zapchandids'); 3124 if ($tableinfo[0]['type'] != 'string') { 3125 $sql = "ALTER TABLE zapchandids CHANGE COLUMN channel channel VARCHAR(40)"; 3126 $results = $db->query($sql); 3127 if (DB::IsError($results)) {die_freepbx($results->getMessage()."<br><br>".$sql);} 3128 } 3129 } 3130 3073 3131 $description = q($description); 3074 3132 $channel = q($channel); 3075 3133 $did = q($did); -
old/module.xml
old new 54 54 <users needsenginedb="yes" sort="-3">Users</users> 55 55 <devices needsenginedb="yes" sort="-4">Devices</devices> 56 56 <did category="Inbound Call Control" sort="-5">Inbound Routes</did> 57 <zapchandids category="Inbound Call Control" sort="-5"> ZapChannel DIDs</zapchandids>57 <zapchandids category="Inbound Call Control" sort="-5">Channel DIDs</zapchandids> 58 58 <routing>Outbound Routes</routing> 59 59 <trunks>Trunks</trunks> 60 60 <general>General Settings</general> -
old/page.zapchandids.php
old new 71 71 $channel = $row['channel']; 72 72 $did = $row['did']; 73 73 74 echo "<h2>"._("Edit ZapChannel: ").$channel."</h2>";74 echo "<h2>"._("Edit Channel: ").$channel."</h2>"; 75 75 } else { 76 echo "<h2>"._("Add ZapChannel")."</h2>";76 echo "<h2>"._("Add Channel")."</h2>"; 77 77 } 78 78 79 $helptext = _(" Zap Channel DIDs allow you to assign a DID to specific Zap Channels. You can supply the same DID to multiple channels. This would be a common scenario if you have multiple POTS lines that are on a hunt group from your provider. You MUST assign the channel's context to from-zaptel for these settings to have effect. It will be a line that looks like:<br /><br />context = from-zaptel<br /><br />in your zapata.conf configuration effecting the specified channel(s). Once you have assigned DIDs you can use standard Inbound Routes with the specified DIDs to route your calls.");79 $helptext = _("Channel DIDs allow you to assign a DID to specific Channels. You can supply the same DID to multiple channels. This would be a common scenario if you have multiple POTS lines that are on a hunt group from your provider. For DAHDI/ZAP channels, you MUST assign the channel's context to from-zaptel for these settings to have effect. It will be a line that looks like:<br /><br />context = from-zaptel<br /><br />in your zapata.conf configuration effecting the specified channel(s). For sip trunk channels you MUST set the channel's context to from-trunk-sip-TRUNKNAME. Once you have assigned DIDs you can use standard Inbound Routes with the specified DIDs to route your calls."); 80 80 echo "<p>".$helptext."</p>\n"; 81 81 ?> 82 82 <form name="editZapchandid" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkZapchandid(editZapchandid);"> … … 89 89 if ($extdisplay == '') { 90 90 ?> 91 91 <tr> 92 <td><a href="#" class="info"><?php echo _("Channel")?>:<span><?php echo _("The Zap Channel numberto map to a DID")?></span></a></td>93 <td><input size=" 5" type="text" name="channel" value="<?php echo $channel; ?>" tabindex="<?php echo ++$tabindex;?>"></td>92 <td><a href="#" class="info"><?php echo _("Channel")?>:<span><?php echo _("The Channel to map to a DID")?></span></a></td> 93 <td><input size="40" type="text" name="channel" value="<?php echo $channel; ?>" tabindex="<?php echo ++$tabindex;?>"></td> 94 94 </tr> 95 95 <?php 96 96 } … … 100 100 <td><input size="40" type="text" name="description" value="<?php echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td> 101 101 </tr> 102 102 <tr> 103 <td><a href="#" class="info"><?php echo _("DID")?>:<span><?php echo _("The DID that this channel represents. The incoming call on this channel will be treated as if it came in with this DID and can be managed with Inbound Routing on DIDs ")?></span></a></td>103 <td><a href="#" class="info"><?php echo _("DID")?>:<span><?php echo _("The DID that this channel represents. The incoming call on this channel will be treated as if it came in with this DID and can be managed with Inbound Routing on DIDs. For SIP channels you may use the magic string 'siptoheader' if you want the DID to be retrieved dynamically from the To: header of the SIP message.")?></span></a></td> 104 104 <td><input size="40" type="text" name="did" value="<?php echo $did; ?>" tabindex="<?php echo ++$tabindex;?>"/></td> 105 105 </tr> 106 106 … … 120 120 var actionDelete = false; 121 121 122 122 function checkZapchandid(theForm) { 123 var msgInvalidChannel = "<?php echo _('Invalid Channel Number, must be numeric and notblank'); ?>";123 var msgInvalidChannel = "<?php echo _('Invalid Channel Number, must not be blank'); ?>"; 124 124 var msgInvalidDID = "<?php echo _('Invalid DID, must be a non-blank DID'); ?>"; 125 125 var msgConfirmDIDNonStd = "<?php echo _('DID information is normally just an incoming telephone number.\n\nYou have entered a non standard DID pattern.\n\nAre you sure this is correct?'); ?>"; 126 126 var msgConfirmConvertDID = "<?php echo _('You appear to be using a converted DID in the form of zapchanNN that was automatically generated during an upgrade. You should consider assigning the DID that is normally associated with this channel to take full advantage of the inbound routing abilities. Changing the DID here will require you to make changes in the Inbound Routes tab. Do you want to continue?'); ?>"; … … 134 134 // form validation 135 135 136 136 defaultEmptyOK = false; 137 if ( !isInteger(theForm.channel.value)) {137 if (isEmpty(theForm.channel.value)) { 138 138 return warnInvalid(theForm.channel, msgInvalidChannel); 139 139 } 140 140 if (isEmpty(theForm.did.value)) {
