Changeset 9265

Show
Ignore:
Timestamp:
03/18/10 01:07:40 (2 years ago)
Author:
p_lindheimer
Message:

adopt new dialrule APIs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.8/sipstation/module.xml

    r9253 r9265  
    22  <rawname>sipstation</rawname> 
    33  <name>SIPSTATION</name> 
    4   <version>2.8.0.1</version> 
     4  <version>2.8.0.2</version> 
    55  <type>setup</type> 
    66  <category>Basic</category> 
     
    1414  <license>COMMERCIAL</license> 
    1515  <changelog> 
     16    *2.8.0.2* switch to new trunk dialrule apis 
    1617    *2.8.0.1* report proper TEMPNOTAVAIL status when server replies with that, minor changes to install script 
    1718    *2.8.0.0* update to use new Outbound Route APIs 
  • modules/branches/2.8/sipstation/routes.html.php

    r9124 r9265  
    5151  if (isset($_POST['areacode']) && trim($_POST['areacode']) != "") { 
    5252 
    53     /* We are adding a prefix, make sure it is 3 digits, then rip out any existing 
    54        7 digit dialing prefix in the current pattern before inserting this at th
    55        top. Validation is kind of 'ghetto', we cleans it,  
     53    /* We are adding a prefix, make sure it is 3 digits, then grab what's there 
     54       rip it out if it is in there, push it on top and if the two differ, updat
     55       if replacing, the old one will be further down and be dumped as a duplicate 
    5656    */ 
    5757    $areacode = preg_replace("/[^0-9]/" ,"",trim($_POST['areacode'])); 
    5858    if (strlen($areacode) == 3) { 
    59       $areacode = "1$areacode+NXXXXXX"; 
    6059      foreach (array($trunknum1,$trunknum2) as $trunk) { 
    61         $dialrules = array(); 
    62         if ($temp = core_trunks_getDialRules($trunk)) { 
    63           foreach ($temp as $key=>$val) { 
    64             $temp2[] = $val; // for later comparison 
    65             // extract all ruleXX keys 
    66             if (preg_match("/^rule\d+$/",$key)) { 
    67               if (!preg_match("/^1[\d]{3}\+NXXXXXX$/",$val)) { 
    68                 $dialrules[] = $val; 
    69               } 
    70             } 
     60        $dialrules = core_trunks_get_dialrules($trunk); 
     61        if (is_array($dialrules) && count($dialrules)) { 
     62          foreach ($dialrules as $rule) { 
     63            $match   = $rule['match_pattern_pass']; 
     64            $prefix  = $rule['match_pattern_prefix']; 
     65            $prepend = $rule['prepend_digits']; 
     66 
     67            $dialrules_tmp[] = array('match_pattern_prefix' => $prefix, 'match_pattern_pass' => $match, 'prepend_digits' => $prepend); 
     68            if ($match != 'NXXXXXX' || $prepend != $areacode || $prefix != '') { 
     69              $dialrules_2[] = array('match_pattern_prefix' => $prefix, 'match_pattern_pass' => $match, 'prepend_digits' => $prepend); 
     70            } 
    7171          } 
    7272        } else { 
    73           $temp = array(); 
     73          $dialrules_2 = array(); 
     74          $dialrules_tmp = array(); 
    7475        } 
    75         array_unshift($dialrules,$areacode); 
    76         if ($temp2 != $dialrules) { 
    77           core_trunks_addDialRules($trunk, $dialrules); 
     76        array_unshift($dialrules_2, array('match_pattern_prefix' => '', 'match_pattern_pass' => 'NXXXXXX', 'prepend_digits' => $areacode)); 
     77         
     78        if ($dialrules_2 != $dialrules_tmp) { 
     79          core_trunks_update_dialrules($trunk, $dialrules_2, true); 
    7880          $need_reload = true; 
    7981        } 
    80         unset($temp); 
    81         unset($temp2); 
     82        unset($dialrules_2); 
     83        unset($dialrules_tmp); 
    8284        unset($dialrules); 
    8385      } 
     
    130132    $json_array['status_message'] = sprintf(_("Successfully configured %s routes to use your SIP trunks"),$cnt); 
    131133  } elseif ($need_reload) { 
    132     $json_array['status_message'] = _("Your Area Code was updated"); 
     134    $json_array['status_message'] = sprintf(_("Your Area Code was updated to %s"),$areacode); 
    133135  } else { 
    134     $json_array['status_message'] = _("No updates were required, nothing was changed in"); 
     136    $json_array['status_message'] = _("No updates were required, no routes or areacode were changed"); 
    135137  } 
    136138} else { 
  • modules/branches/2.8/sipstation/sipstation.html.php

    r9124 r9265  
    141141  // 
    142142  $json_array['areacode'] = ""; 
    143   if ($temp = core_trunks_getDialRules($trunknum1)) { 
    144     foreach ($temp as $key=>$val) { 
    145       // extract all ruleXX keys 
    146       if (preg_match("/^rule\d+$/",$key)) { 
    147         if (preg_match("/^1([\d]{3})\+NXXXXXX$/",$val,$matches)) { 
    148           $json_array['areacode'] = $matches[1]; 
    149           break; 
    150         } 
     143  $dialrules = core_trunks_get_dialrules($trunknum1); 
     144  if (is_array($dialrules) && count($dialrules)) { 
     145    foreach ($dialrules as $rule) { 
     146      if (preg_match('/^1{0,1}(\d{3})$/',$rule['prepend_digits'],$matches)) { 
     147        $json_array['areacode'] = $matches[1]; 
     148        break; 
    151149      } 
    152150    } 
  • modules/branches/2.8/sipstation/sipstation.utility.php

    r9218 r9265  
    348348  $peerdetails .= "username=$sip_user\nsecret=$sip_pass\nhost="; 
    349349  $register    = "$sip_user:$sip_pass@"; 
    350   $dialrules   = array(); 
    351350 
    352351  for ($i=1;$i<3;$i++) { 
     
    368367    } else { 
    369368      $trunknum = core_trunks_add($tech, $channelid, '', '', $default_did, $peerdetails.$gw, '', '', $register.$gw, $keepcid, '', $disabletrunk); 
    370       core_trunks_addDialRules($trunknum, $dialrules); 
    371369      $globalvar = "OUT_".$trunknum; 
    372370      $need_reload = true;