Changeset 5566

Show
Ignore:
Timestamp:
01/10/08 14:06:39 (5 years ago)
Author:
p_lindheimer
Message:

fix bug in core_trunks_list(true) that could not handle same name of different technologies, requires dashboard fix which also uses this routine. Add partial support for DUNDi trunks in FreePBX (required manual configuration of dundi.conf, but full support to use in routing/trunks once configured

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.4/core/functions.inc.php

    r5563 r5566  
    943943              $ext->add($trunkcontext, '_.', '', new ext_goto('1','${EXTEN}','from-trunk')); 
    944944              break; 
     945            case 'DUNDI': 
     946              $macro_name = 'macro-dundi-'.substr($trunkprops['globalvar'],4); 
     947              $ext->addSwitch($macro_name,'DUNDI/'.$trunkprops['name']); 
     948              $ext->add($macro_name, 's', '', new ext_goto('1','${ARG1}')); 
     949              break; 
    945950            default: 
    946951          } 
     
    10181023          if(strpos($exten['args'],"MOHCLASS") !== false) 
    10191024            $ext->add($outrt['application'], $exten['extension'], '', new ext_setvar("MOHCLASS", '${IF($["x${MOHCLASS}"="x"]?'.substr($exten['args'],9).':${MOHCLASS})}' )); 
    1020           if(strpos($exten['args'],"dialout-trunk") !== false || strpos($exten['args'],"dialout-enum") !== false) { 
     1025          if(strpos($exten['args'],"dialout-trunk") !== false || strpos($exten['args'],"dialout-enum") !== false || strpos($exten['args'],"dialout-dundi") !== false) { 
    10211026            if ($exten['extension'] !== $lastexten) { 
    10221027 
     
    10391044        } 
    10401045      } 
     1046 
    10411047      general_generate_indications(); 
    10421048 
     
    11721178 
    11731179 
     1180 
     1181 
     1182      $context = 'macro-dialout-dundi'; 
     1183      $exten = 's'; 
     1184       
     1185      /* 
     1186       * Dialout Dundi Trunk 
     1187       */ 
     1188      $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK', '${ARG1}')); 
     1189      $ext->add($context, $exten, '', new ext_execif('$[$["${ARG3}" != ""] & $["${DB(AMPUSER/${AMPUSER}/pinless)}" != "NOPASSWD"]]', 'Authenticate', '${ARG3}')); 
     1190      $ext->add($context, $exten, '', new ext_gotoif('$["x${OUTDISABLE_${DIAL_TRUNK}}" = "xon"]', 'disabletrunk,1')); 
     1191      $ext->add($context, $exten, '', new ext_set('DIAL_NUMBER', '${ARG2}')); // fixlocalprefix depends on this 
     1192      $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', '${DIAL_OPTIONS}')); // will be reset to TRUNK_OPTIONS if not intra-company 
     1193      $ext->add($context, $exten, '', new ext_set('GROUP()', 'OUT_${DIAL_TRUNK}')); 
     1194      $ext->add($context, $exten, '', new ext_gotoif('$["${OUTMAXCHANS_${DIAL_TRUNK}}foo" = "foo"]', 'nomax')); 
     1195      $ext->add($context, $exten, '', new ext_gotoif('$[ ${GROUP_COUNT(OUT_${DIAL_TRUNK})} > ${OUTMAXCHANS_${DIAL_TRUNK}} ]', 'chanfull')); 
     1196      $ext->add($context, $exten, 'nomax', new ext_gotoif('$["${INTRACOMPANYROUTE}" = "YES"]', 'skipoutcid'));  // Set to YES if treated like internal 
     1197      $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', '${TRUNK_OPTIONS}')); 
     1198      $ext->add($context, $exten, '', new ext_macro('outbound-callerid', '${DIAL_TRUNK}')); 
     1199      $ext->add($context, $exten, 'skipoutcid', new ext_agi('fixlocalprefix'));  // this sets DIAL_NUMBER to the proper dial string for this trunk 
     1200      $ext->add($context, $exten, '', new ext_set('OUTNUM', '${OUTPREFIX_${DIAL_TRUNK}}${DIAL_NUMBER}'));  // OUTNUM is the final dial number 
     1201 
     1202      // Back to normal processing, whether intracompany or not. 
     1203      // But add the macro-setmusic if we don't want music on this outbound call 
     1204      $ext->add($context, $exten, '', new ext_gotoif('$[$["${MOHCLASS}" = "default"] | $["foo${MOHCLASS}" = "foo"]]', 'gocall'));  // Set to YES if we should pump silence 
     1205      $ext->add($context, $exten, '', new ext_set('DIAL_TRUNK_OPTIONS', 'M(setmusic^${MOHCLASS})${DIAL_TRUNK_OPTIONS}'));  // set MoH or off 
     1206     
     1207      // This macro call will always be blank and is provided as a hook for customization required prior to making a call 
     1208      // such as adding SIP header information or other requirements. All the channel variables from above are present 
     1209       
     1210      $ext->add($context, $exten, 'gocall', new ext_macro('dialout-trunk-predial-hook')); 
     1211      $ext->add($context, $exten, '', new ext_gotoif('$["${PREDIAL_HOOK_RET}" = "BYPASS"]', 'bypass,1')); 
     1212     
     1213      $ext->add($context, $exten, '', new ext_gotoif('$["${custom}" = "AMP"]', 'customtrunk')); 
     1214 
     1215      $ext->add($context, $exten, '', new ext_macro('dundi-${DIAL_TRUNK}','${OUTNUM}')); 
     1216      $ext->add($context, $exten, '', new ext_goto(1, 's-${DIALSTATUS}')); 
     1217       
     1218      $ext->add($context, $exten, 'chanfull', new ext_noop('max channels used up')); 
     1219     
     1220      $exten = 's-BUSY'; 
     1221      $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting BUSY - giving up')); 
     1222      $ext->add($context, $exten, '', new ext_playtones('busy')); 
     1223      $ext->add($context, $exten, '', new ext_busy(20)); 
     1224     
     1225      $exten = 's-NOANSWER'; 
     1226      $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting NOANSWER - giving up')); 
     1227      $ext->add($context, $exten, '', new ext_playtones('congestion')); 
     1228      $ext->add($context, $exten, '', new ext_congestion(20)); 
     1229     
     1230      $exten = 's-CANCEL'; 
     1231      $ext->add($context, $exten, '', new ext_noop('Dial failed due to trunk reporting CANCEL - giving up')); 
     1232      $ext->add($context, $exten, '', new ext_playtones('congestion')); 
     1233      $ext->add($context, $exten, '', new ext_congestion(20)); 
     1234     
     1235      $exten = '_s-.'; 
     1236      $ext->add($context, $exten, '', new ext_gotoif('$["x${OUTFAIL_${ARG1}}" = "x"]', 'noreport')); 
     1237      $ext->add($context, $exten, '', new ext_agi('${OUTFAIL_${ARG1}}')); 
     1238      $ext->add($context, $exten, 'noreport', new ext_noop('TRUNK Dial failed due to ${DIALSTATUS} - failing through to other trunks')); 
     1239       
     1240      $ext->add($context, 'disabletrunk', '', new ext_noop('TRUNK: ${OUT_${DIAL_TRUNK}} DISABLED - falling through to next trunk')); 
     1241      $ext->add($context, 'bypass', '', new ext_noop('TRUNK: ${OUT_${DIAL_TRUNK}} BYPASSING because dialout-trunk-predial-hook')); 
     1242     
     1243      $ext->add($context, 'h', '', new ext_macro('hangupcall')); 
     1244 
     1245 
     1246 
    11741247      /* 
    11751248       * sets the callerid of the device to that of the logged in user 
     
    27832856    foreach ($unique_trunks as $trunk) { 
    27842857      list($tech,$name) = explode('/',$trunk[1]); 
    2785       $trunkinfo[$name] = array( 
     2858      $trunkinfo[$trunk[1]] = array( 
    27862859        'name' => $name, 
    27872860        'tech' => $tech, 
     
    29893062 
    29903063  if ($amp_conf["AMPDBENGINE"] == "sqlite3") 
    2991     $sql_code = "SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
     3064    $sql_code = "SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%' OR args LIKE 'dialout-dundi,".$trunknum.",%') ORDER BY context"; 
    29923065  else 
    2993     $sql_code = "SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
     3066    $sql_code = "SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%' OR args LIKE 'dialout-dundi,".$trunknum.",%') ORDER BY context"; 
    29943067 
    29953068  $results = sql( $sql_code, "getAll" ); 
     
    33273400        $pass_str = ""; 
    33283401 
    3329       if ($trunktech[$trunk] == "ENUM") 
     3402      if ($trunktech[$trunk] == "ENUM") { 
    33303403        $sql .= "'dialout-enum,".substr($trunk,4).",\${".$exten."},".$pass_str."'"; // cut off OUT_ from $trunk 
    3331       else 
     3404      } else if ($trunktech[$trunk] == "DUNDI") { 
     3405        $sql .= "'dialout-dundi,".substr($trunk,4).",\${".$exten."},".$pass_str."'"; // cut off OUT_ from $trunk 
     3406      } else { 
    33323407        $sql .= "'dialout-trunk,".substr($trunk,4).",\${".$exten."},".$pass_str."'"; // cut off OUT_ from $trunk 
     3408      } 
    33333409      $sql .= ")"; 
    33343410       
     
    34453521function core_routing_getroutepatterns($route) { 
    34463522  global $db; 
    3447   $sql = "SELECT extension, args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk%' OR args LIKE'dialout-enum%') ORDER BY extension "; 
     3523  $sql = "SELECT extension, args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk%' OR args LIKE 'dialout-enum%' OR args LIKE 'dialout-dundi%') ORDER BY extension "; 
    34483524  $results = $db->getAll($sql); 
    34493525  if(DB::IsError($results)) { 
     
    34733549function core_routing_getroutetrunks($route) { 
    34743550  global $db; 
    3475   $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%') ORDER BY CAST(priority as UNSIGNED) "; 
     3551  $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY CAST(priority as UNSIGNED) "; 
    34763552  $results = $db->getAll($sql); 
    34773553  if(DB::IsError($results)) { 
     
    34913567        $trunks[] = "OUT_".$matches[1]; 
    34923568      } 
     3569    } else if (preg_match('/^dialout-dundi,(\d+)/', $row[0], $matches)) { 
     3570      if (!in_array("OUT_".$matches[1], $trunks)) { 
     3571        $trunks[] = "OUT_".$matches[1]; 
     3572      } 
    34933573    } 
    34943574  } 
     
    35003580function core_routing_getroutepassword($route) { 
    35013581  global $db; 
    3502   $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%') ORDER BY CAST(priority as UNSIGNED) "; 
     3582  $sql = "SELECT DISTINCT args FROM extensions WHERE context = 'outrt-".$route."' AND (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY CAST(priority as UNSIGNED) "; 
    35033583  $results = $db->getOne($sql); 
    35043584  if(DB::IsError($results)) { 
  • modules/branches/2.4/core/page.trunks.php

    r5353 r5566  
    1212//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1313//GNU General Public License for more details. 
    14  
    1514 
    1615 
     
    173172} 
    174173   
    175  
    176    
    177174//get all rows from globals 
    178175$sql = "SELECT * FROM globals"; 
     
    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 { 
     
    232230    $failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; 
    233231    $disabletrunk = isset(${"OUTDISABLE_".$trunknum})?${"OUTDISABLE_".$trunknum}:''; 
     232 
    234233     
    235234    if ($tech!="enum") { 
     
    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)) {  
     
    270269      unset($temp); 
    271270    } 
    272      
     271 
    273272    echo "<h2>".sprintf(_("Edit %s Trunk"),strtoupper($tech))."</h2>"; 
    274273?> 
     
    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   
     
    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  ?> 
     
    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)) 
     
    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);  
  • modules/branches/2.4/dashboard/class.astinfo.php

    r5356 r5566  
    103103        $online = !empty($matches[6]);  
    104104 
    105         if (isset($trunks[$matches[2]])) { 
     105        if (isset($trunks['SIP/'.$matches[2]])) { 
    106106          // this is a trunk 
    107107          //TODO match trunk tech as well?  
     
    143143        $online = !empty($matches[6]);  
    144144 
    145         if (isset($trunks[$matches[2]])) { 
     145        if (isset($trunks['IAX2/'.$matches[2]])) { 
    146146          // this is a trunk 
    147147          //TODO match trunk tech as well?