Ticket #2591: trunks.patch

File trunks.patch, 10.2 kB (added by ded, 4 years ago)
  • page.trunks.php

    old new  
    1 <?php /* $Id: page.trunks.php 5353 2007-12-05 22:09:16Z p_lindheimer $ */ 
     1<?php /* $Id: page.trunks.php 5615 2008-01-26 19:50:13Z p_lindheimer $ */ 
    22// routing.php Copyright (C) 2004 Greg MacLellan (greg@mtechsolutions.ca) 
    33// Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) 
    44// 
     
    1313//GNU General Public License for more details. 
    1414 
    1515 
    16  
    1716$display='trunks';  
    1817$extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; 
    1918$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 
     
    172171  break; 
    173172} 
    174173   
    175  
    176    
    177174//get all rows from globals 
    178175$sql = "SELECT * FROM globals"; 
    179176$globals = $db->getAll($sql); 
     
    197194$tresults = core_trunks_list(); 
    198195 
    199196foreach ($tresults as $tresult) { 
    200   $background = ($tresult[2] == 'on')?'#DDD':'#FFF'; 
    201   echo "\t<li><a ".($extdisplay==$tresult[0] ? 'class="current"':'')." href=\"config.php?display=".urlencode($display)."&amp;extdisplay=".urlencode($tresult[0])."\" title=\"".urlencode($tresult[1])."\" style=\"background: $background;\" >"._("Trunk")." ".substr(ltrim($tresult[1],"AMP:"),0,15)."</a></li>\n"; 
     197  $background = ($tresult[2] == 'on')?'#DDD':''; 
     198  echo "\t<li><a ".($extdisplay==$tresult[0] ? 'class="current"':'')." href=\"config.php?display=".urlencode($display)."&amp;extdisplay=".urlencode($tresult[0])."\" title=\"".urlencode($tresult[1])."\" style=\"background: $background;\" >"._("Trunk")." ".substr(str_replace('AMP:', '', $tresult[1]),0,15)."</a></li>\n"; 
    202199} 
    203200 
    204201?> 
     
    217214  <a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&amp;tech=SIP"><?php echo _("Add SIP Trunk")?></a><br><br> 
    218215  <a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&amp;tech=ENUM"><?php echo _("Add ENUM Trunk")?></a><br><br> 
    219216  <a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&amp;tech=CUSTOM"><?php echo _("Add Custom Trunk")?></a><br><br> 
     217  <a href="<?php echo $_SERVER['PHP_SELF'].'?display='.urlencode($display); ?>&amp;tech=DUNDI"><?php echo _("Add DUNDi Trunk")?></a><br><br> 
    220218<?php  
    221219} else { 
    222220  if ($extdisplay) { 
     
    231229    $failtrunk = isset(${"OUTFAIL_".$trunknum})?${"OUTFAIL_".$trunknum}:''; 
    232230    $failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; 
    233231    $disabletrunk = isset(${"OUTDISABLE_".$trunknum})?${"OUTDISABLE_".$trunknum}:''; 
     232 
    234233     
    235234    if ($tech!="enum") { 
    236235   
     
    238237        $channelid = core_trunks_getTrunkTrunkName($trunknum);  
    239238      } 
    240239 
    241       if ($tech!="custom") {  // custom trunks will not have user/peer details in database table 
     240      if ($tech!="custom" && $tech!="dundi") {  // custom trunks will not have user/peer details in database table 
    242241        // load from db 
    243242        if (!isset($peerdetails)) {  
    244243          $peerdetails = core_trunks_getTrunkPeerDetails($trunknum); 
     
    269268      } 
    270269      unset($temp); 
    271270    } 
    272      
     271 
    273272    echo "<h2>".sprintf(_("Edit %s Trunk"),strtoupper($tech))."</h2>"; 
    274273?> 
    275274    <p><a title="<?php echo $channelid ?>" href="config.php?display=<?php echo urlencode($display) ?>&amp;extdisplay=<?php echo urlencode($extdisplay) ?>&amp;action=deltrunk"><?php echo _("Delete Trunk")?> <?php  echo substr($channelid,0,20); ?></a></p> 
     
    313312    $areacode = ""; 
    314313   
    315314    echo "<h2>".sprintf("Add %s Trunk",strtoupper($tech))."</h2>"; 
     315 
    316316  }  
     317switch ($tech) { 
     318  case 'dundi': 
     319    $helptext = _("FreePBX offers limited support for DUNDi trunks and additional manual configuration is required. The trunk name should correspond to the [mappings] section of the remote dundi.conf systems. For example, you may have a mapping on the remote system, and corresponding configurations in dundi.conf locally, that looks as follows:<br /><br />[mappings]<br />priv => dundi-extens,0,IAX2,priv:${SECRET}@218.23.42.26/${NUMBER},noparital<br /><br />In this example, you would create this trunk and name it priv. You would then create the corresponding IAX2 trunk with proper settings to work with DUNDi. This can be done by making an IAX2 trunk in FreePBX or by using the iax_custom.conf file.<br />The dundi-extens context in this example must be created in extensions_custom.conf. This can simply include contexts such as ext-local, ext-intercom-users, ext-paging and so forth to provide access to the corresponding extensions and features provided by these various contexts and generated by FreePBX."); 
     320    break; 
     321  default: 
     322    $helptext = ''; 
     323} 
     324if ($helptext != '') { 
     325  if ($extdisplay) { 
     326    echo "<br /><br />"; 
     327  } 
     328  echo $helptext; 
     329} 
     330     
    317331?> 
    318332   
    319333    <form name="trunkEdit" action="config.php" method="post" onsubmit="return trunkEdit_onsubmit('<?php echo ($extdisplay ? "edittrunk" : "addtrunk") ?>');"> 
     
    345359<?php 
    346360  if ($tech == "sip" || substr($tech,0,3) == "iax") { 
    347361?> 
    348           <a href=# class="info"><?php echo _("Maximum Channels")?><span><?php echo sprintf(_("Controls the maximum number of outbound channels (simultaneous calls) that can be used on this trunk. To count inbound calls against this maximum, use the auto-generated context: %s as the inbound trunk's context. (see extensions_additional.conf) Leave blank to specify no maximum."),((isset($channelid) && trim($channelid)!="")?"from-trunk-$channelid":"from-trunk-[trunkname]"))?></span></a>:  
     362          <a href=# class="info"><?php echo _("Maximum Channels")?><span><?php echo sprintf(_("Controls the maximum number of outbound channels (simultaneous calls) that can be used on this trunk. To count inbound calls against this maximum, use the auto-generated context: %s as the inbound trunk's context. (see extensions_additional.conf) Leave blank to specify no maximum."),((isset($channelid) && trim($channelid)!="")?"from-trunk-$tech-$channelid":"from-trunk-[trunkname]"))?></span></a>:  
    349363<?php 
    350364  } else { 
    351365?> 
     
    494508        do { 
    495509          var localprefix = <?php echo 'prompt("'._("What prefix should be removed from the number?\\n\\n(ie. for US/CAN, 1+areacode, ie, \'1613\')").'")'?>; 
    496510          if (localprefix == null) return; 
    497         } while (!localprefix.match('^[0-9#*ZXN\.]+$') && <?php echo '!alert("'._('Invalid prefix. Only 0-9, #, *, Z, N, and X are allowed.').'")'?>); 
     511        } while (!localprefix.match('^[0-9#*ZXN\.]+$') && <?php echo '!alert("'._("Invalid prefix. Only 0-9, #, *, Z, N, and X are allowed.").'")'?>); 
    498512         
    499513        do { 
    500514          var localpattern = <?php echo 'prompt("'._("What is the dialing pattern for local numbers after")?> "+localprefix+"? \n\n<?php echo _("(ie. NXXNXXXXXX for US/CAN 10-digit dialing, NXXXXXX for 7-digit)").'"'?>,"NXXXXXX"); 
     
    663677        </tr>  
    664678  <?php 
    665679    break; 
     680    case "dundi": 
     681  ?> 
     682        <tr> 
     683          <td> 
     684            <a href=# class="info"><?php echo _("DUNDi Mapping")?><span><?php echo _("This is the name of the DUNDi mapping as defined in the [mappings] section of remote dundi.conf peers. This corresponds to the 'include' section of the peer details in the local dundi.conf file. This requires manual configuration of DUNDi to use this trunk.")?></span></a>:  
     685          </td><td> 
     686            <input type="text" size="35" maxlength="46" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>"/> 
     687            <input type="hidden" size="14" name="usercontext" value="notneeded"/> 
     688          </td> 
     689        </tr>  
     690  <?php 
     691    break; 
    666692    default: 
    667693  ?> 
    668694        <tr> 
     
    740766theForm.outcid.focus(); 
    741767 
    742768function trunkEdit_onsubmit(act) { 
    743   var msgInvalidOutboundCID = "<?php echo _('Invalid Outbound Caller ID'); ?>"; 
    744   var msgInvalidMaxChans = "<?php echo _('Invalid Maximum Channels'); ?>"; 
    745   var msgInvalidDialRules = "<?php echo _('Invalid Dial Rules'); ?>"; 
    746   var msgInvalidOutboundDialPrefix = "<?php echo _('Invalid Outbound Dial Prefix'); ?>"; 
    747   var msgInvalidTrunkName = "<?php echo _('Invalid Trunk Name entered'); ?>"; 
    748   var msgInvalidChannelName = "<?php echo _('Invalid Custom Dial String entered'); ?>";  
    749   var msgInvalidTrunkAndUserSame = "<?php echo _('Trunk Name and User Context cannot be set to the same value'); ?>"; 
    750   var msgConfirmBlankContext = "<?php echo _('User Context was left blank and User Details will not be saved!'); ?>"; 
    751   var msgNeverOverrideCIDValue = "<?php echo _('You must define an Outbound Caller ID when Choosing Never Override CallerID'); ?>"; 
     769  var msgInvalidOutboundCID = "<?php echo _("Invalid Outbound Caller ID"); ?>"; 
     770  var msgInvalidMaxChans = "<?php echo _("Invalid Maximum Channels"); ?>"; 
     771  var msgInvalidDialRules = "<?php echo _("Invalid Dial Rules"); ?>"; 
     772  var msgInvalidOutboundDialPrefix = "<?php echo _("Invalid Outbound Dial Prefix"); ?>"; 
     773  var msgInvalidTrunkName = "<?php echo _("Invalid Trunk Name entered"); ?>"; 
     774  var msgInvalidChannelName = "<?php echo _("Invalid Custom Dial String entered"); ?>";  
     775  var msgInvalidTrunkAndUserSame = "<?php echo _("Trunk Name and User Context cannot be set to the same value"); ?>"; 
     776  var msgConfirmBlankContext = "<?php echo _("User Context was left blank and User Details will not be saved!"); ?>"; 
     777  var msgNeverOverrideCIDValue = "<?php echo _("You must define an Outbound Caller ID when Choosing Never Override CallerID"); ?>"; 
    752778 
    753779  defaultEmptyOK = true; 
    754780 
     
    767793  if (!isDialIdentifierSpecial(theForm.dialoutprefix.value)) 
    768794    return warnInvalid(theForm.dialoutprefix, msgInvalidOutboundDialPrefix); 
    769795   
    770   <?php if ($tech != "enum" && $tech != "custom") { ?> 
     796  <?php if ($tech != "enum" && $tech != "custom" && $tech != "dundi") { ?> 
    771797  defaultEmptyOK = true; 
    772798  if (isEmpty(theForm.channelid.value) || isWhitespace(theForm.channelid.value)) 
    773799    return warnInvalid(theForm.channelid, msgInvalidTrunkName); 
    774800   
    775801  if (theForm.channelid.value == theForm.usercontext.value) 
    776802    return warnInvalid(theForm.usercontext, msgInvalidTrunkAndUserSame); 
    777   <?php } else if ($tech == "custom") { ?>  
     803  <?php } else if ($tech == "custom" || $tech == "dundi") { ?>  
    778804  if (isEmpty(theForm.channelid.value) || isWhitespace(theForm.channelid.value))  
    779805    return warnInvalid(theForm.channelid, msgInvalidChannelName);  
    780806