Changeset 9087

Show
Ignore:
Timestamp:
03/07/10 00:02:51 (3 years ago)
Author:
p_lindheimer
Message:

additional work towards new outbound route schema re #4110 still not and minimal tested

Files:

Legend:

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

    r9081 r9087  
    15761576 
    15771577if (false) { // new outbound routes 
    1578       $ext->addInclude('from-internal-additional','outbound-allroutes'); 
    1579       $ext->add('outbound-allroutes', '_!', '', new ext_macro('user-callerid,SKIPTTL')); 
     1578      $ext->addInclude('from-internal-additional','outbound-allroutes-byid'); 
     1579      $ext->add('outbound-allroutes-byid', '_!', '', new ext_macro('user-callerid,SKIPTTL')); 
    15801580      $routes = core_routing_list(); 
    15811581      $trunk_table = core_trunks_listbyid(); 
     
    15861586          if (is_array($times) && count($times)) { 
    15871587            foreach ($times as $time) { 
    1588               $ext->addInclude('outbound-allroutes',$context.'|'.$time[1]); 
     1588              $ext->addInclude('outbound-allroutes-byid',$context.'|'.$time[1]); 
    15891589            } 
    15901590          } else { 
    1591             $ext->addInclude('outbound-allroutes',$context); 
     1591            $ext->addInclude('outbound-allroutes-byid',$context); 
    15921592          } 
    15931593        } else { 
    1594           $ext->addInclude('outbound-allroutes',$context); 
     1594          $ext->addInclude('outbound-allroutes-byid',$context); 
    15951595        } 
    15961596 
     
    16001600        foreach ($patterns as $pattern) { 
    16011601          $exten = $pattern['match_pattern_prefix'].$pattern['match_pattern_pass']; 
     1602          $cid = $pattern['match_cid']; 
     1603 
     1604          //TODO: does the plus need to be backslashed? 
     1605          if (!preg_match("/^[0-9*+]+$/",$exten)) {  
     1606            // note # is not here, as asterisk doesn't recoginize it as a normal digit, thus it requires _ pattern matching 
     1607            // it's not strictly digits, so it must have patterns, so prepend a _ 
     1608            $exten = "_".$exten; 
     1609          } 
     1610          if (!preg_match("/^[0-9*+]+$/",$cid)) {  
     1611            // note # is not here, as asterisk doesn't recoginize it as a normal digit, thus it requires _ pattern matching 
     1612            // it's not strictly digits, so it must have patterns, so prepend a _ 
     1613            $cid = "_".$cid; 
     1614          } 
     1615          if ($cid != '') { 
     1616            $exten .= '/'.$cid; 
     1617          } 
     1618 
    16021619          $ext->add($context, $exten, '', new ext_noop('Macro(user-callerid): executed in outbound-allroutes PRI 1'));  
    16031620          if ($route['emergencyy_route'] != '') { 
     
    45334550 
    45344551function core_trunks_listbyid() { 
    4535   $result = sql('SELECT * from `trunks` ORDER BY `trunkid`'); 
     4552  $result = sql('SELECT * from `trunks` ORDER BY `trunkid`','getAll',DB_FETCHMODE_ASSOC); 
    45364553  $trunk_list = array(); 
    45374554  foreach ($result as $trunk) { 
     4555    if ($trunk['name'] == '') { 
     4556      $tech = strtoupper($trunk['tech']); 
     4557      switch ($tech) { 
     4558        case 'IAX': 
     4559          $trunk['name'] = 'IAX2/'.$trunk['channelid']; 
     4560          break; 
     4561        case 'CUSTOM': 
     4562          $trunk['name'] = 'AMP:'.$trunk['channelid']; 
     4563          break; 
     4564        default: 
     4565          $trunk['name'] = $tech.'/'.$trunk['channelid']; 
     4566          break; 
     4567      } 
     4568    } 
    45384569    $trunk_list[$trunk['trunkid']] = $trunk; 
    45394570  } 
     
    47924823function core_routing_get($route_id) { 
    47934824  global $db; 
    4794   $sql = 'SELECT * FROM `outbound_routes` WHERE route_id='.$db->escapeSimple($cidnum); 
     4825  $sql = 'SELECT * FROM `outbound_routes` WHERE route_id='.$db->escapeSimple($route_id); 
    47954826  $route = sql($sql,"getRow",DB_FETCHMODE_ASSOC); 
    47964827  return $route; 
     
    48134844    die_freepbx($sequence->getDebugInfo());  
    48144845  } 
    4815   echo "route_id: $route_id, seq: $seq\n"; 
    4816   print_r($sequence); 
    48174846 
    48184847  $key = array_search($route_id,$sequence); 
     
    48974926// function core_routing_rename($oldname, $newname) 
    48984927function core_routing_renamebyid($route_id, $new_name) { 
    4899   $db; 
     4928  global $db; 
    49004929  $route_id = $db->escapeSimple($route_id); 
    49014930  $new_name = $db->escapeSimple($new_name); 
     
    49054934// function core_routing_getroutepatterns($route) 
    49064935function core_routing_getroutepatternsbyid($route_id) { 
    4907   $db; 
     4936  global $db; 
    49084937  $route_id = $db->escapeSimple($route_id); 
    49094938  $sql = "SELECT * FROM `outbound_route_patterns` WHERE `route_id` = $route_id ORDER BY `match_pattern_prefix`, `match_pattern_pass`"; 
     
    49144943// function core_routing_getroutetrunks($route) 
    49154944function core_routing_getroutetrunksbyid($route_id) { 
    4916   $db; 
     4945  global $db; 
    49174946  $route_id = $db->escapeSimple($route_id); 
    49184947  $sql = "SELECT `trunk_id` FROM `outbound_route_trunks` WHERE `route_id` = $route_id ORDER BY `seq`"; 
     
    49785007      $db->escapeSimple($pattern['match_pattern_prefix']), 
    49795008      $db->escapeSimple($pattern['match_pattern_pass']), 
     5009      $db->escapeSimple($pattern['match_cid']), 
    49805010      $db->escapeSimple($pattern['prepend_digits']), 
    49815011    ); 
     
    49845014    $sql('DELETE FROM `outbound_route_patterns` WHERE `route_id`='.$route_id); 
    49855015  } 
    4986   $compiled = $db->prepare('INSERT INTO `outbound_route_patterns` (`match_pattern_prefix`, `match_pattern_pass`, `prepend_digits`) VALUES (?,?,?)'); 
     5016  $compiled = $db->prepare('INSERT INTO `outbound_route_patterns` (`match_pattern_prefix`, `match_pattern_pass`, `match_cid`, `prepend_digits`) VALUES (?,?,?,?)'); 
    49875017  $result = $db->executeMultiple($compiled,$insert_pattern); 
    49885018  if(DB::IsError($result)) {