Ticket #3549: func.core.php-sipchandid.patch

File func.core.php-sipchandid.patch, 5.1 kB (added by Nick_Lewis, 3 years ago)
  • old/functions.inc.php

    old new  
    10091009           
    10101010      } 
    10111011 
    1012       // Now create macro-from-zaptel-nnn for each defined channel to route it to the DID routing 
     1012      // Now create macro-from-channel-nnn for each defined channel to route it to the DID routing 
    10131013      // Send it to from-trunk so it is handled as other dids would be handled. 
    10141014      // 
    10151015      foreach (core_zapchandids_list() as $row) { 
    10161016        $channel = $row['channel']; 
    10171017        $did     = $row['did']; 
    10181018 
    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):5}')); 
     1025          $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID','${CUT(DID,@,1)}')); 
     1026          $ext->add($channel_context, 's', '', new ext_noop('Used sip To: header to set DID = ${FROM_DID}')); 
     1027          $ext->add($channel_context, 's', '', new ext_goto('1','${FROM_DID}','from-trunk')); 
     1028        } else { 
     1029          $ext->add($channel_context, 's', '', new ext_noop('Entering '.$channel_context.' with DID = ${DID} and setting to: '.$did)); 
     1030          $ext->add($channel_context, 's', '', new ext_setvar('__FROM_DID',$did)); 
     1031          $ext->add($channel_context, 's', '', new ext_goto('1',$did,'from-trunk')); 
     1032        } 
    10231033      } 
    10241034 
    10251035      /* user extensions */ 
     
    11341144            case 'IAX2': 
    11351145            case 'SIP': 
    11361146              $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')); 
     1147              $context  = "from-trunk-".strtolower($trunkprops['tech'])."-".$trunkprops['name']; 
     1148 
     1149              $exten = '_.'; 
     1150       
     1151              $ext->add($context, $exten, '', new ext_set('DID', '${EXTEN}')); 
     1152              $ext->add($context, $exten, '', new ext_goto(1, 's')); 
     1153 
     1154              $exten = 's'; 
     1155              $ext->add($context, $exten, '', new ext_noop('Entering '.$context.' with DID == ${DID}')); 
     1156              $ext->add($context, $exten, '', new ext_setvar('GROUP()',$trunkgroup)); 
     1157              // Some trunks _require_ a RINGING be sent before an Answer.  
     1158              $ext->add($context, $exten, '', new ext_ringing()); 
     1159              // If ($did == "") { $did = "s"; } 
     1160              $ext->add($context, $exten, '', new ext_set('DID', '${IF($["${DID}"= ""]?s:${DID})}')); 
     1161              $ext->add($context, $exten, '', new ext_noop('DID is now ${DID}')); 
     1162              $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:3}"="SIP"]', 'trunkok', 'nottrunk')); 
     1163              $ext->add($context, $exten, 'nottrunk', new ext_goto('1', '${DID}', 'from-trunk')); 
     1164              // If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup. 
     1165              $ext->add($context, $exten, '', new ext_macro('Hangupcall', 'dummy')); 
     1166              $ext->add($context, $exten, 'trunkok', new ext_noop('Is a SIP Trunk Channel')); 
     1167              $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:4}')); 
     1168              $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); 
     1169              $ext->add($context, $exten, '', new ext_macro('from-channel-${CHAN}', '${DID},1')); 
     1170              // If nothing there, then treat it as a DID 
     1171              $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-channel-${CHAN}')); 
     1172              $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-trunk')); 
     1173 
     1174 
    11401175              break; 
    11411176            default: 
    11421177          } 
     
    18741909        $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:4}')); 
    18751910      }        
    18761911      $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); 
    1877       $ext->add($context, $exten, '', new ext_macro('from-zaptel-${CHAN}', '${DID},1')); 
     1912      $ext->add($context, $exten, '', new ext_macro('from-channel-${CHAN}', '${DID},1')); 
    18781913      // If nothing there, then treat it as a DID 
    1879       $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-zaptel-${CHAN}')); 
     1914      $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-channel-${CHAN}')); 
    18801915      $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-pstn')); 
    18811916      $ext->add($context, 'fax', '', new ext_goto(1, 'in_fax', 'ext-fax')); 
    18821917 
     
    30413076  global $db; 
    30423077 
    30433078 
    3044   if (!ctype_digit(trim($channel)) || trim($channel) == '') { 
    3045     echo "<script>javascript:alert('"._("Invalid Channel Number, must be numeric and not blank")."')</script>"; 
     3079  if (trim($channel) == '') { 
     3080    echo "<script>javascript:alert('"._("Invalid Channel Number, must not be blank")."')</script>"; 
    30463081    return false; 
    30473082  } 
    30483083  if (trim($did) == '') {