Changeset 7783

Show
Ignore:
Timestamp:
05/31/09 12:31:28 (3 years ago)
Author:
p_lindheimer
Message:

closes #3702 auto generate a context for sip and iax trunks that have none or blank contexts specified

Files:

Legend:

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

    r7759 r7783  
    247247      unset($results2_pre); 
    248248 
     249      $context=''; 
    249250      foreach ($results2 as $result2) { 
    250         $option = $result2['data']
     251        $option = strtolower($result2['data'])
    251252        if ($ver12) { 
    252           $output .= $result2['keyword']."=$option\n"; 
     253          switch (strtolower($result2['keyword'])) { 
     254            case 'context': 
     255              $context = $option; 
     256              //fall-through 
     257            default: 
     258              $output .= $result2['keyword']."=".$result2['data']."\n"; 
     259          } 
    253260        } else { 
    254261          switch (strtolower($result2['keyword'])) { 
     
    259266                $output .= "insecure=port\n"; 
    260267              else 
    261                 $output .= $result2['keyword']."=$option\n"; 
     268                $output .= $result2['keyword']."=".$result2['data']."\n"; 
    262269              break; 
    263270            case 'allow': 
    264271            case 'disallow': 
    265272              if ($option != '') 
    266                 $output .= $result2['keyword']."=$option\n"; 
     273                $output .= $result2['keyword']."=".$result2['data']."\n"; 
    267274              break; 
    268275            case 'record_in': 
    269276            case 'record_out': 
    270277              break; 
     278            case 'context': 
     279              $context = $result2['data']; 
     280              //fall-through 
    271281            default: 
    272               $output .= $result2['keyword']."=$option\n"; 
     282              $output .= $result2['keyword']."=".$result2['data']."\n"; 
    273283          } 
    274284        } 
    275285      } 
    276       if ($call_limit && (!preg_match('/^tr-peer-*|^tr-user-*|^tr-reg-*/',$id))) { 
    277         $output .= $call_limit; 
     286      switch (substr($id,0,8)) { 
     287        case 'tr-peer-': 
     288          if ($context == '') { 
     289            $output .= "context=from-trunk-sip-$account\n"; 
     290          } 
     291          break; 
     292        case 'tr-user-': 
     293          if ($context == '') { 
     294            $tn = substr($id, 8); 
     295            // this is a 'user' trunk, we need to get the name of the corresponding 'peer' 
     296            // trunk so we can set the context appropriately for the group count 
     297            // 
     298            $td = core_trunks_getDetails($tn); 
     299            if (isset($td['channelid'])) { 
     300              $output .= "context=from-trunk-sip-".$td['channelid']."\n"; 
     301            } 
     302          } 
     303          break; 
     304        default: 
     305          if ($call_limit) { 
     306            $output .= $call_limit; 
     307          } 
    278308      } 
    279309      $output .= $additional."\n"; 
     
    375405      unset($results2_pre); 
    376406 
     407      $context=''; 
    377408      foreach ($results2 as $result2) { 
    378         $option = $result2['data']
     409        $option = strtolower($result2['data'])
    379410        if ($ver12) { 
    380           $output .= $result2['keyword']."=$option\n"; 
     411          switch (strtolower($result2['keyword'])) { 
     412            case 'context': 
     413              $context = $result2['data']; 
     414              //fall-through 
     415            default: 
     416              $output .= $result2['keyword']."=".$result2['data']."\n"; 
     417          } 
    381418        } else { 
    382419          switch ($result2['keyword']) { 
     
    389426                $output .= "transfer=mediaonly\n"; 
    390427              } else { 
    391                 $output .= $result2['keyword']."=$option\n"; 
     428                $output .= $result2['keyword']."=".$result2['data']."\n"; 
    392429              } 
    393430              break; 
     
    395432            case 'disallow': 
    396433              if ($option != '') 
    397                 $output .= $result2['keyword']."=$option\n"; 
     434                $output .= $result2['keyword']."=".$result2['data']."\n"; 
    398435              break; 
    399436            case 'record_in': 
    400437            case 'record_out': 
    401438              break; 
     439            case 'context': 
     440              $context = $option; 
     441              //fall-through 
    402442            default: 
    403               $output .= $result2['keyword']."=$option\n"; 
     443              $output .= $result2['keyword']."=".$result2['data']."\n"; 
    404444          } 
    405445        } 
     446      } 
     447      switch (substr($id,0,8)) { 
     448        case 'tr-peer-': 
     449          if ($context == '') { 
     450            $output .= "context=from-trunk-iax2-$account\n"; 
     451          } 
     452          break; 
     453        case 'tr-user-': 
     454          if ($context == '') { 
     455            $tn = substr($id, 8); 
     456            // this is a 'user' trunk, we need to get the name of the corresponding 'peer' 
     457            // trunk so we can set the context appropriately for the group count 
     458            // 
     459            $td = core_trunks_getDetails($tn); 
     460            if (isset($td['channelid'])) { 
     461              $output .= "context=from-trunk-iax2-".$td['channelid']."\n"; 
     462            } 
     463          } 
     464          break; 
     465        default: 
     466          if ($call_limit) { 
     467            $output .= $call_limit; 
     468          } 
    406469      } 
    407470      $output .= $additional."\n"; 
  • modules/branches/2.6/core/module.xml

    r7760 r7783  
    88  <canuninstall>no</canuninstall> 
    99  <changelog> 
    10     *2.6.0beta1.1* #3696 (needs framework updated) 
     10    *2.6.0beta1.1* #3696, (needs framework updated), #3702 
    1111    *2.6.0beta1.0* #3478, #3423, #3648, #3685, #3686, #1380 
    1212    *2.6.0alpha1.4* fixes re #3649