Changeset 9210

Show
Ignore:
Timestamp:
03/13/10 01:44:59 (2 years ago)
Author:
p_lindheimer
Message:

closes #2833 add trunks as a destination option

Files:

Legend:

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

    r9137 r9210  
    629629    } 
    630630  } 
     631 
     632  $trunklist = core_trunks_listbyid(); 
     633  if (is_array($trunklist)) foreach ($trunklist as $trunk) { 
     634    switch($trunk['tech']) { 
     635      case 'enum': 
     636        break; 
     637      default: 
     638        $extens[] = array('destination' => 'ext-trunk,'.$trunk['trunkid'].',1', 'description' => $trunk['name'].' ('.$trunk['tech'].')', 'category' => 'Trunks'); 
     639        break; 
     640    } 
     641  } 
    631642   
    632643  if (isset($extens)) 
     
    638649function core_getdest($exten) { 
    639650  $dests[] = 'from-did-direct,'.$exten.',1'; 
     651  $dests[] = 'ext-trunk,'.$exten.',1'; 
    640652  if (!function_exists('voicemail_mailbox_get')) { 
    641653    return $dests; 
     
    670682                   'edit_url' => "config.php?type=setup&display=$display&extdisplay=".urlencode($exten)."&skip=0", 
    671683                  ); 
     684    } 
     685 
     686 
     687  } else if (substr(trim($dest),0,10) == 'ext-trunk,') { 
     688    $exten = explode(',',$dest); 
     689    $exten = $exten[1]; 
     690    $thisexten = core_trunks_getDetails($exten); 
     691    if (empty($thisexten)) { 
     692      return array(); 
     693    } else { 
     694      $display = 'trunks'; 
     695      return array('description' => sprintf(_('Trunk: %s (%s)'),$thisexten['name'],$thisexten['tech']), 
     696                  'edit_url' => "config.php?type=setup&display=$display&extdisplay=OUT_".urlencode($exten), 
     697                  ); 
     698 
    672699    } 
    673700 
     
    13091336      } 
    13101337 
    1311  
    1312       // create from-trunk context for each trunk that adds counts to channels 
    1313       // 
    1314       $trunklist = core_trunks_list(true); 
    1315       if (is_array($trunklist)) { 
     1338      /* Create the from-trunk-tech-chanelid context that can be used for inbound group counting 
     1339       * Create the DUNDI macros for DUNDI trunks 
     1340       * Create the ext-trunk context for direct trunk dialing TODO: should this be its own module? 
     1341       */ 
     1342      $trunklist = core_trunks_listbyid(); 
     1343      if (is_array($trunklist) && count($trunklist)) { 
     1344 
     1345        $tcontext = 'ext-trunk'; 
     1346        $texten = 'tdial'; 
     1347        $tcustom = 'tcustom'; 
     1348        $generate_texten = false; 
     1349        $generate_tcustom = false; 
     1350 
    13161351        foreach ($trunklist as $trunkprops) { 
    1317           if (trim($trunkprops['value']) == 'on') { 
    1318             // value of on is disabled and for zap we don't create a context 
     1352          if (trim($trunkprops['disabled']) == 'on') { 
    13191353            continue; 
    13201354          } 
    13211355          switch ($trunkprops['tech']) { 
    1322             case 'DUNDI': 
    1323               $macro_name = 'macro-dundi-'.substr($trunkprops['globalvar'],4)
    1324               $ext->addSwitch($macro_name,'DUNDI/'.$trunkprops['name']); 
     1356            case 'dundi': 
     1357              $macro_name = 'macro-dundi-'.$trunkprops['trunkid']
     1358              $ext->addSwitch($macro_name,'DUNDI/'.$trunkprops['channelid']); 
    13251359              $ext->add($macro_name, 's', '', new ext_goto('1','${ARG1}')); 
    1326             case 'IAX': 
    1327             case 'IAX2': 
    1328             case 'SIP': 
    1329               $trunkgroup = $trunkprops['globalvar']; 
    1330               $trunkcontext  = "from-trunk-".strtolower($trunkprops['tech'])."-".$trunkprops['name']; 
    1331               $ext->add($trunkcontext, '_.', '', new ext_setvar('GROUP()',$trunkgroup)); 
     1360 
     1361              $trunkgroup = 'OUT_'.$trunkprops['trunkid']; 
     1362              $trunkcontext  = "from-trunk-".$trunkprops['tech']."-".$trunkprops['channelid']; 
     1363              $ext->add($trunkcontext, '_.', '', new ext_set('GROUP()',$trunkgroup)); 
    13321364              $ext->add($trunkcontext, '_.', '', new ext_goto('1','${EXTEN}','from-trunk')); 
     1365 
     1366              $ext->add($tcontext,$trunkprops['trunkid'],'',new ext_set('OUTBOUND_GROUP', 'OUT_${DIAL_TRUNK}')); 
     1367              $ext->add($tcontext,$trunkprops['trunkid'],'',new ext_gotoif('$["${OUTMAXCHANS_${DIAL_TRUNK}}" = ""]', 'nomax')); 
     1368              $ext->add($tcontext,$trunkprops['trunkid'],'',new ext_gotoif('$[${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}}]', 'hangit')); 
     1369              if ($ast_lt_16) {  
     1370                $ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}')); 
     1371              } else { 
     1372                $ext->add($tcontext,$trunkprops['trunkid'],'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}')); 
     1373              } 
     1374              $ext->add($tcontext,$trunkprops['trunkid'],'',new ext_set('DIAL_NUMBER','${FROM_DID}')); 
     1375              $ext->add($tcontext,$trunkprops['trunkid'],'',new ext_execif('$["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]','AGI','fixlocalprefix')); 
     1376              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_macro('dundi-${DIAL_TRUNK}','${OUTNUM}')); 
     1377              $ext->add($tcontext,$trunkprops['trunkid'],'hangit',new ext_hangup()); 
     1378              break; 
     1379 
     1380            case 'iax': 
     1381              $trukprops['tech'] = 'iax2'; 
     1382              // fall-through 
     1383            case 'iax2': 
     1384            case 'sip': 
     1385              $trunkgroup = 'OUT_'.$trunkprops['trunkid']; 
     1386              $trunkcontext  = "from-trunk-".$trunkprops['tech']."-".$trunkprops['channelid']; 
     1387              $ext->add($trunkcontext, '_.', '', new ext_set('GROUP()',$trunkgroup)); 
     1388              $ext->add($trunkcontext, '_.', '', new ext_goto('1','${EXTEN}','from-trunk')); 
     1389              // fall-through 
     1390            case 'zap': 
     1391            case 'dahdi': 
     1392              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_set('TDIAL_STRING',strtoupper($trunkprops['tech']).'/'.$trunkprops['channelid'])); 
     1393              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_set('DIAL_TRUNK',$trunkprops['trunkid'] )); 
     1394              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_goto('1',$texten,'ext-trunk')); 
     1395              $generate_texten = true; 
     1396              break; 
     1397 
     1398            // TODO we don't have the OUTNUM until later so fix this... 
     1399            case 'custom': 
     1400              $dial_string = str_replace('$OUTNUM$','\\\\$\\\\{OUTNUM\\\\}',$trunkprops['channelid']); 
     1401              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_set('TDIAL_STRING',$dial_string)); 
     1402              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_set('DIAL_TRUNK',$trunkprops['trunkid'] )); 
     1403              $ext->add($tcontext, $trunkprops['trunkid'], '', new ext_goto('1',$tcustom,'ext-trunk')); 
     1404              $generate_tcustom = true; 
     1405              break; 
     1406 
     1407            case 'enum': 
     1408              // Not Supported 
    13331409              break; 
    13341410            default: 
    13351411          } 
    13361412        } 
    1337       } 
    1338  
     1413 
     1414        if ($generate_tcustom) { 
     1415          $ext->add($tcontext,$tcustom,'',new ext_set('OUTBOUND_GROUP', 'OUT_${DIAL_TRUNK}')); 
     1416          $ext->add($tcontext,$tcustom,'',new ext_gotoif('$["${OUTMAXCHANS_${DIAL_TRUNK}}" = ""]', 'nomax')); 
     1417          $ext->add($tcontext,$tcustom,'',new ext_gotoif('$[${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}}]', 'hangit')); 
     1418          if ($ast_lt_16) {  
     1419            $ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}')); 
     1420          } else { 
     1421            $ext->add($tcontext,$tcustom,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}')); 
     1422          } 
     1423          $ext->add($tcontext,$tcustom,'',new ext_set('DIAL_NUMBER','${FROM_DID}')); 
     1424          $ext->add($tcontext,$tcustom,'',new ext_execif('$["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]','AGI','fixlocalprefix')); 
     1425          $ext->add($tcontext,$tcustom,'',new ext_dial('${EVAL(${TDIAL_STRING})}','300,${DIAL_TRUNK_OPTIONS}')); 
     1426          $ext->add($tcontext,$tcustom,'hangit',new ext_hangup()); 
     1427        } 
     1428 
     1429        if ($generate_texten) { 
     1430          $ext->add($tcontext,$texten,'',new ext_set('OUTBOUND_GROUP', 'OUT_${DIAL_TRUNK}')); 
     1431          $ext->add($tcontext,$texten,'',new ext_gotoif('$["${OUTMAXCHANS_${DIAL_TRUNK}}" = ""]', 'nomax')); 
     1432          $ext->add($tcontext,$texten,'',new ext_gotoif('$[${GROUP_COUNT(OUT_${DIAL_TRUNK})} >= ${OUTMAXCHANS_${DIAL_TRUNK}}]', 'hangit')); 
     1433          if ($ast_lt_16) {  
     1434            $ext->add($tcontext,$texten,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'SetCallerPres', '${CALLINGPRES_SV}')); 
     1435          } else { 
     1436            $ext->add($tcontext,$texten,'nomax',new ext_execif('$["${CALLINGPRES_SV}" != ""]', 'Set', 'CALLERPRES()=${CALLINGPRES_SV}')); 
     1437          } 
     1438          $ext->add($tcontext,$texten,'',new ext_set('DIAL_NUMBER','${FROM_DID}')); 
     1439          $ext->add($tcontext,$texten,'',new ext_execif('$["${PREFIX_TRUNK_${DIAL_TRUNK}}" != ""]','AGI','fixlocalprefix')); 
     1440          $ext->add($tcontext,$texten,'',new ext_dial('${TDIAL_STRING}/${OUTNUM}','300,${DIAL_TRUNK_OPTIONS}')); 
     1441          $ext->add($tcontext,$texten,'hangit',new ext_hangup()); 
     1442        } 
     1443      } 
    13391444      /* dialplan globals */ 
    13401445      // modules should NOT use the globals table to store anything! 
     
    19422047      $ext->add($context, $exten, '', new ext_gotoif('$["${PREDIAL_HOOK_RET}" = "BYPASS"]', 'bypass,1')); 
    19432048     
    1944       $ext->add($context, $exten, '', new ext_gotoif('$["${custom}" = "AMP"]', 'customtrunk')); 
    1945  
    19462049      $ext->add($context, $exten, '', new ext_macro('dundi-${DIAL_TRUNK}','${OUTNUM}')); 
    19472050      $ext->add($context, $exten, '', new ext_goto(1, 's-${DIALSTATUS}')); 
  • modules/branches/2.8/core/module.xml

    r9207 r9210  
    1010  <canuninstall>no</canuninstall> 
    1111  <changelog> 
    12     *2.8.0.0beta1.1* #4132 
     12    *2.8.0.0beta1.1* #4132, #2833 
    1313    *2.8.0.0beta1.0* #4100, #4102, #4110 New Outbound Routing Schema and features 
    1414    *2.7.0.2* really fix #4092 
  • modules/branches/2.8/core/page.trunks.php

    r8913 r9210  
    299299      echo "</span></a>"; 
    300300    } 
     301    $usage_list = framework_display_destination_usage(core_getdest(ltrim($extdisplay,'OUT_'))); 
     302    if (!empty($usage_list)) { 
     303    ?> 
     304      <a href="#" class="info"><?php echo $usage_list['text']?><span><?php echo $usage_list['tooltip']?></span></a> 
     305    <?php 
     306    } 
     307 
    301308 
    302309  } else {