Changeset 8041

Show
Ignore:
Timestamp:
08/14/09 20:39:37 (4 years ago)
Author:
p_lindheimer
Message:

added Descritpion field to trunk page and renamed the Never Overide CallerID for clearity along with other cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.6/core/module.xml

    r8021 r8041  
    44  <category>Basic</category> 
    55  <name>Core</name> 
    6   <version>2.6.0beta1.2</version> 
     6  <version>2.6.0beta1.3</version> 
    77  <publisher>FreePBX</publisher> 
    88  <license>GPLv2+</license> 
     
    1010  <canuninstall>no</canuninstall> 
    1111  <changelog> 
     12    *2.6.0beta1.3* trunk tab improvements 
    1213    *2.6.0beta1.2* added more sql escape in devices 
    1314    *2.6.0beta1.1* #3696, (needs framework updated), #3702, #3706, #3712, #3691, #3693, #3705, #3644, #3739, #3741, #3744, #3790  
  • modules/branches/2.6/core/page.trunks.php

    r7880 r8041  
    2121$display='trunks';  
    2222$extdisplay=isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:''; 
     23$trunknum = ltrim($extdisplay,'OUT_'); 
     24 
    2325$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; 
    24 $tech = strtolower(isset($_REQUEST['tech'])?$_REQUEST['tech']:''); 
    25  
    26 $trunknum = ltrim($extdisplay,'OUT_'); 
    27  
    28  
    29 // populate some global variables from the request string 
    30 $set_globals = array("outcid","maxchans","dialoutprefix","channelid","peerdetails","usercontext","userconfig","register","keepcid","failtrunk","disabletrunk"); 
    31 foreach ($set_globals as $var) { 
    32   if (isset($_REQUEST[$var])) { 
    33     $$var = stripslashes( $_REQUEST[$var] ); 
    34   } 
    35 
    36  
    37 // ensure that keepcid is set to something: 
    38 if (!isset($keepcid)) { 
    39   $keepcid = "off"; 
    40 
    41 // ensure that failtrunk is set to something: 
    42 if (!isset($failtrunk)) { 
    43   $failtrunk = ""; 
    44 
     26 
     27$tech         = strtolower(isset($_REQUEST['tech'])?$_REQUEST['tech']:''); 
     28$outcid       = isset($_REQUEST['outcid'])?$_REQUEST['outcid']:''; 
     29$maxchans     = isset($_REQUEST['maxchans'])?$_REQUEST['maxchans']:''; 
     30$dialoutprefix= isset($_REQUEST['dialoutprefix'])?$_REQUEST['dialoutprefix']:''; 
     31$channelid    = isset($_REQUEST['channelid'])?$_REQUEST['channelid']:''; 
     32$peerdetails  = isset($_REQUEST['peerdetails'])?$_REQUEST['peerdetails']:''; 
     33$usercontext  = isset($_REQUEST['usercontext'])?$_REQUEST['usercontext']:''; 
     34$userconfig   = isset($_REQUEST['userconfig'])?$_REQUEST['userconfig']:''; 
     35$register     = isset($_REQUEST['register'])?$_REQUEST['register']:''; 
     36$keepcid      = isset($_REQUEST['keepcid'])?$_REQUEST['keepcid']:'off'; 
     37$disabletrunk = isset($_REQUEST['disabletrunk'])?$_REQUEST['disabletrunk']:'off'; 
     38$provider     = isset($_REQUEST['provider'])?$_REQUEST['provider']:''; 
     39$trunk_name   = isset($_REQUEST['trunk_name'])?$_REQUEST['trunk_name']:''; 
     40 
     41$failtrunk    = isset($_REQUEST['failtrunk'])?$_REQUEST['failtrunk']:''; 
    4542$failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; 
    4643 
    47 if (!isset($disabletrunk)) { 
    48   $disabletrunk = "off"; 
    49 } 
    50  
    5144if (isset($_REQUEST["dialrules"])) { 
    52   //$dialpattern = $_REQUEST["dialpattern"]; 
    5345  $dialrules = explode("\n",$_REQUEST["dialrules"]); 
    5446 
     
    7466switch ($action) { 
    7567  case "addtrunk": 
    76     if (!isset($failtrunk)) 
    77         $failtrunk=""; 
    78     $trunknum = core_trunks_add($tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk),$disabletrunk); 
     68    $trunknum = core_trunks_add($tech, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk, $trunk_name, $provider); 
    7969     
    8070    core_trunks_addDialRules($trunknum, $dialrules); 
     
    8373  break; 
    8474  case "edittrunk": 
    85     if (!isset($failtrunk)) 
    86         $failtrunk=""; 
    87     core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk); 
    88      
    89     /* //DIALRULES 
    90     deleteTrunkRules($channelid); 
    91     addTrunkRules($channelid, $dialrules); 
    92     */ 
     75    core_trunks_edit($trunknum, $channelid, $dialoutprefix, $maxchans, $outcid, $peerdetails, $usercontext, $userconfig, $register, $keepcid, trim($failtrunk), $disabletrunk, $trunk_name, $provider); 
    9376     
    9477    // this can rewrite too, so edit is the same 
     
    10083   
    10184    core_trunks_del($trunknum); 
     85    core_trunks_deleteDialRules($trunknum); 
    10286    core_routing_trunk_del($trunknum); 
    103      
    104     /* //DIALRULES 
    105     deleteTrunkRules($channelid); 
    106     */ 
    107     core_trunks_deleteDialRules($trunknum); 
    10887    needreload(); 
    10988    redirect_standard(); 
     
    178157} 
    179158   
    180 //get all rows from globals 
    181 $sql = "SELECT * FROM globals"; 
    182 $globals = $db->getAll($sql); 
    183 if(DB::IsError($globals)) { 
    184   die_freepbx($globals->getMessage()); 
    185 } 
    186  
    187 //create a set of variables that match the items in global[0] 
    188 foreach ($globals as $global) { 
    189   ${trim($global[0])} = htmlentities($global[1]); 
    190 } 
    191  
    192159?> 
    193160</div> 
     
    198165<?php  
    199166//get existing trunk info 
    200 $tresults = core_trunks_list(); 
     167$tresults = core_trunks_getDetails(); 
     168//$tresults = core_trunks_list(); 
    201169 
    202170foreach ($tresults as $tresult) { 
    203   $background = ($tresult[2] == 'on')?'#DDD':''; 
    204   echo "\t<li><a ".($extdisplay==$tresult[0] ? 'class="current"':'')." href=\"config.php?display=".urlencode($display)."&amp;extdisplay=".urlencode($tresult[0])."\" title=\"".urlencode($tresult[1])."\" style=\"background: $background;\" >"._("Trunk")." ".substr(str_replace('AMP:', '', $tresult[1]),0,15)."</a></li>\n"; 
     171  $background = ($tresult['disabled'] == 'on')?'#DDD':''; 
     172  switch ($tresult['tech']) { 
     173    case 'enum': 
     174      $label = substr($tresult['name'],0,15)." ENUM"; 
     175      break; 
     176    case 'dundi': 
     177      $label = substr($tresult['name'],0,15)." (DUNDi)"; 
     178      break; 
     179    case 'iax2': 
     180      $tresult['tech'] = 'iax'; 
     181    case 'zap': 
     182    case 'dahdi': 
     183    case 'sip': 
     184    case 'iax': 
     185    case 'custom': 
     186    default: 
     187      $label = substr($tresult['name'],0,15)." (".$tresult['tech'].")"; 
     188      break; 
     189  } 
     190  echo "\t<li><a ".($trunknum==$tresult['trunkid'] ? 'class="current"':'')." href=\"config.php?display=".urlencode($display)."&amp;extdisplay=OUT_".urlencode($tresult['trunkid'])."\" title=\"".urlencode($tresult['name'])."\" style=\"background: $background;\" >".$label."</a></li>\n"; 
    205191} 
    206192 
     
    219205  $trunks = array( 
    220206    array('url'=> $baseURL.'tech=ZAP', 'tlabel' =>  _("Add Zap Trunk").(ast_with_dahdi()?" ("._("DAHDI compatibility mode").")":"" )), 
     207    array('url'=> $baseURL.'tech=SIP', 'tlabel' =>  _("Add SIP Trunk")), 
    221208    array('url'=> $baseURL.'tech=IAX2', 'tlabel' =>  _("Add IAX2 Trunk")), 
    222     array('url'=> $baseURL.'tech=SIP', 'tlabel' =>  _("Add SIP Trunk")), 
    223209    array('url'=> $baseURL.'tech=ENUM', 'tlabel' =>  _("Add ENUM Trunk")), 
    224210    array('url'=> $baseURL.'tech=DUNDI', 'tlabel' =>  _("Add DUNDi Trunk")), 
     
    242228    $failtrunk_enable = ($failtrunk == "")?'':'CHECKED'; 
    243229    $disabletrunk = htmlentities($trunk_details['disabled']); 
     230    $provider = $trunk_details['provider']; 
     231    $trunk_name = htmlentities($trunk_details['name']); 
    244232     
    245233    if ($tech!="enum") { 
     
    249237      if ($tech!="custom" && $tech!="dundi") {  // custom trunks will not have user/peer details in database table 
    250238        // load from db 
    251         if (!isset($peerdetails)) {  
     239        if (empty($peerdetails)) {   
    252240          $peerdetails = core_trunks_getTrunkPeerDetails($trunknum); 
    253241        } 
    254    
    255         if (!isset($usercontext)) {  
     242        if (empty($usercontext)) {   
    256243          $usercontext = htmlentities($trunk_details['usercontext']); 
    257244        } 
    258245   
    259         if (!isset($userconfig)) {   
     246        if (empty($userconfig)) {  
    260247          $userconfig = core_trunks_getTrunkUserConfig($trunknum); 
    261248        } 
    262249           
    263         if (!isset($register)) {   
     250        if (empty($register)) {  
    264251          $register = core_trunks_getTrunkRegister($trunknum); 
    265252        } 
    266253      } 
    267254    } 
    268      
    269255    if (count($dialrules) == 0) { 
    270256      if ($temp = core_trunks_getDialRules($trunknum)) { 
     
    279265    } 
    280266 
    281  
    282267    $upper_tech = strtoupper($tech); 
    283268    echo "<h2>".sprintf(_("Edit %s Trunk"),$upper_tech).($upper_tech == 'ZAP' && ast_with_dahdi()?" ("._("DAHDI compatibility Mode").")":"")."</h2>"; 
    284     $tlabel = sprintf(_("Delete Trunk %s"),substr($channelid,0,20)); 
     269    $tname = $trunk_name != '' ? $trunk_name : $channelid; 
     270    $tlabel = sprintf(_("Delete Trunk %s"),substr($tname,0,20)); 
    285271    $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/core_delete.png"/>&nbsp;'.$tlabel.'</span>'; 
    286272?> 
     
    332318    $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.'); 
    333319    break; 
     320  case 'sip': 
     321    break; 
    334322  default: 
    335323    $helptext = ''; 
     
    349337      <input type="hidden" name="action" value=""/> 
    350338      <input type="hidden" name="tech" value="<?php echo $tech?>"/> 
     339      <input type="hidden" name="provider" value="<?php echo $provider?>"/> 
    351340      <table> 
    352341      <tr> 
     
    357346      <tr> 
    358347        <td> 
    359           <a href=# class="info"><?php echo _("Outbound Caller ID")?><span><br><?php echo _("Caller ID for calls placed out on this trunk<br><br>Format: <b>\"caller name\" &lt;#######&gt;</b>. You can also use the magic string 'hidden' to hide the CallerID sent out over Digital lines ONLY (E1/T1/J1/BRI/SIP/IAX)")?><br><br></span></a>:  
     348          <a href=# class="info"><?php echo _("Trunk Description")?><span><br><?php echo _("Descriptive Name for this Trunk")?><br><br></span></a>:  
    360349        </td><td> 
    361           <input type="text" size="20" name="outcid" value="<?php echo $outcid;?>" tabindex="<?php echo ++$tabindex;?>"/> 
    362         </td> 
    363       </tr> 
    364       <tr> 
    365         <td> 
    366           <a href="#" class="info"><?php echo _("Never Override CallerID")?><span><br><?php echo _("Some VoIP providers will drop the call if you try to send an invalid CallerID (one you don't 'own.' Use this to never send a CallerID that you haven't explicitly specified in this trunk or in the outbound callerid field of an extension/user. You might notice this problem if you discover that Follow-Me or RingGroups with external numbers don't work properly. Checking this box has the effect of disabling 'foreign' callerids from going out this trunk. You must define an Outbound Caller ID on the this trunk when checking this.");?><br /><br /></span></a>: 
     350          <input type="text" size="30" name="trunk_name" value="<?php echo $trunk_name;?>" tabindex="<?php echo ++$tabindex;?>"/> 
     351        </td> 
     352      </tr> 
     353      <tr> 
     354        <td> 
     355          <a href=# class="info"><?php echo _("Outbound Caller ID")?><span><br><?php echo _("Caller ID for calls placed out on this trunk<br><br>Format: <b>&lt;#######&gt;</b>. You can also use the format: \"hidden\" <b>&lt;#######&gt;</b> to hide the CallerID sent out over Digital lines if supported (E1/T1/J1/BRI/SIP/IAX).")?><br><br></span></a>:  
     356        </td><td> 
     357          <input type="text" size="30" name="outcid" value="<?php echo $outcid;?>" tabindex="<?php echo ++$tabindex;?>"/> 
     358        </td> 
     359      </tr> 
     360      <tr> 
     361        <td> 
     362          <a href="#" class="info"><?php echo _("Block Foreign CallerIDs")?><span><br><?php echo _("Some VoIP providers will drop the call if you try to send an invalid CallerID (one you don't 'own.' Use this to never send a CallerID that you haven't explicitly specified in this trunk or in the outbound callerid field of an extension/user. You might notice this problem if you discover that Follow-Me or RingGroups with external numbers don't work properly. Checking this box has the effect of disabling 'foreign' callerids from going out this trunk. You must define an Outbound Caller ID on the this trunk when checking this.");?><br /><br /></span></a>: 
    367363        </td><td> 
    368364          <input type="checkbox" name="keepcid" <?php if ($keepcid=="on") {echo "checked";}?> tabindex="<?php echo ++$tabindex;?>"/> 
     
    394390          </td> 
    395391      </tr> 
    396  
    397392      <tr> 
    398393          <td><a class="info" href="#"><?php echo _("Monitor Trunk Failures")?><span><?php echo _("If checked, supply the name of a custom AGI Script that will be called to report, log, email or otherwise take some action on trunk failures that are not caused by either NOANSWER or CANCEL.")?></span></a>: