Changeset 7893

Show
Ignore:
Timestamp:
07/05/09 13:45:31 (4 years ago)
Author:
p_lindheimer
Message:

Merged revisions 7892 via svnmerge from
http://svn.freepbx.org/modules/branches/2.4

................

r7890 | p_lindheimer | 2009-07-05 10:37:32 -0700 (Sun, 05 Jul 2009) | 1 line


fixes #3744 found a good way to get proper sequences without multiple ugly queries

................

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.3

    • Property svnmerge-integrated changed from /modules/branches/2.2:1-3588,3615-3635,3637-3638,3640,3674,3680,3686,3692,3702,3706,3710,3716,3758,3760,3762-3765,3767-3785,3787-3789,3801,3810,3828,3831,3839,3860,3866,3875,3877,3887,3899,3911,3913,3943,3982-3983,3990,3998,4007,4022-4023,4089,4092,4098,4265,4285 /modules/branches/2.4:1-5079,5090,5093,5097-5118,5120-5170,5172,5174,5176-5182,5184-5199,5202-5203,5205-5211,5239,5271-5272,5312,5383,5516,5544-5545,5548-5549,5555,5564,5570,5572-5574,5576-5578,5596,5606-5610,5612,5615-5618,5623-5624,5628,5630-5642,5644-5646,5648-5651,5653-5654,5656-5657,5660,5687-5699,5701-5702,5704-5715,5723-5727,5729-5730,5733-5741,5752-5753,5756,5830-5831,5842-5843,5881,6280,7876,7881,7887 to /modules/branches/2.2:1-3588,3615-3635,3637-3638,3640,3674,3680,3686,3692,3702,3706,3710,3716,3758,3760,3762-3765,3767-3785,3787-3789,3801,3810,3828,3831,3839,3860,3866,3875,3877,3887,3899,3911,3913,3943,3982-3983,3990,3998,4007,4022-4023,4089,4092,4098,4265,4285 /modules/branches/2.4:1-5079,5090,5093,5097-5118,5120-5170,5172,5174,5176-5182,5184-5199,5202-5203,5205-5211,5239,5271-5272,5312,5383,5516,5544-5545,5548-5549,5555,5564,5570,5572-5574,5576-5578,5596,5606-5610,5612,5615-5618,5623-5624,5628,5630-5642,5644-5646,5648-5651,5653-5654,5656-5657,5660,5687-5699,5701-5702,5704-5715,5723-5727,5729-5730,5733-5741,5752-5753,5756,5830-5831,5842-5843,5881,6280,7876,7881,7887,7892
  • modules/branches/2.3/core/functions.inc.php

    r7889 r7893  
    20612061//get outbound routes for a given trunk 
    20622062function core_trunks_gettrunkroutes($trunknum) { 
    2063   global $amp_conf; 
    2064  
    2065   if ($amp_conf["AMPDBENGINE"] == "sqlite3") 
    2066     $sql_code = "SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
    2067   else 
    2068     $sql_code = "SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%') ORDER BY context"; 
    2069  
    2070   $results = sql( $sql_code, "getAll" ); 
    2071  
    2072   foreach ($results as $row) { 
    2073     // original code was: 
    2074     //  $routes[$row[0]] = $row[1]; 
    2075     // but substring is not supported in sqlite3. 
    2076     // how about we remove the 2nd part of the "if"? and use the same code on all DB's? 
    2077  
    2078     $t = ($amp_conf["AMPDBENGINE"] == "sqlite3") ? substr( $row[0], 7 ) : $row[0]; 
    2079     $r = $row[1]; 
    2080     $routes[ $t ] = $r; 
    2081  
    2082   } 
    2083   // array(routename=>priority) 
    2084   return isset($routes)?$routes:null; 
     2063  $sql_code = "SELECT DISTINCT SUBSTRING(context,7) route ,args trunk FROM extensions WHERE context LIKE 'outrt-%' AND  
     2064    (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY context,priority"; 
     2065  $results = sql( $sql_code, "getAll" ,DB_FETCHMODE_ASSOC); 
     2066  $routeseq = array(); 
     2067  foreach ($results as $entry) { 
     2068    $pos1 = strpos($entry['trunk'],',')+1; 
     2069    $routeseq[$entry['route']][] = substr($entry['trunk'],$pos1,strpos($entry['trunk'],',',$pos1)-$pos1); 
     2070  } 
     2071  $routes = array(); 
     2072  foreach ($routeseq as $key => $value) { 
     2073    $pos = array_search($trunknum, array_values(array_unique($value))); 
     2074    if ($pos !== false) { 
     2075      $routes[$key] = $pos+1; // start at 1, not 0 
     2076    } 
     2077  } 
     2078  return $routes; 
    20852079} 
    20862080