Changeset 7892

Show
Ignore:
Timestamp:
07/05/09 12:40:39 (3 years ago)
Author:
p_lindheimer
Message:

Merged revisions 7890 via svnmerge from
http://svn.freepbx.org/modules/branches/2.5

........

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.4

    • Property svnmerge-integrated changed from /modules/branches/2.3:1-5233,5245,5333,5336 /modules/branches/2.5:1-5852,5880,5930,5995,6016-6017,6030-6031,6142,6218,6291,6361,6363,6413-6414,6422,6428-6430,6442-6443,6557,6710,6714-6715,6969-6970,6984,7248,7281,7858-7859,7875,7878,7886 to /modules/branches/2.3:1-5233,5245,5333,5336 /modules/branches/2.5:1-5852,5880,5930,5995,6016-6017,6030-6031,6142,6218,6291,6361,6363,6413-6414,6422,6428-6430,6442-6443,6557,6710,6714-6715,6969-6970,6984,7248,7281,7858-7859,7875,7878,7886,7890
  • modules/branches/2.4/core/functions.inc.php

    r7887 r7892  
    32193219//get outbound routes for a given trunk 
    32203220function core_trunks_gettrunkroutes($trunknum) { 
    3221   global $amp_conf; 
    3222  
    3223   if ($amp_conf["AMPDBENGINE"] == "sqlite3") 
    3224     $sql_code = "SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%' OR args LIKE 'dialout-dundi,".$trunknum.",%') ORDER BY context"; 
    3225   else 
    3226     $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.",%' OR args LIKE 'dialout-dundi,".$trunknum.",%') ORDER BY context"; 
    3227  
    3228   $results = sql( $sql_code, "getAll" ); 
    3229  
    3230   foreach ($results as $row) { 
    3231     // original code was: 
    3232     //  $routes[$row[0]] = $row[1]; 
    3233     // but substring is not supported in sqlite3. 
    3234     // how about we remove the 2nd part of the "if"? and use the same code on all DB's? 
    3235  
    3236     $t = ($amp_conf["AMPDBENGINE"] == "sqlite3") ? substr( $row[0], 7 ) : $row[0]; 
    3237     $r = $row[1]; 
    3238     $routes[ $t ] = $r; 
    3239  
    3240   } 
    3241   // array(routename=>priority) 
    3242   return isset($routes)?$routes:null; 
     3221  $sql_code = "SELECT DISTINCT SUBSTRING(context,7) route ,args trunk FROM extensions WHERE context LIKE 'outrt-%' AND  
     3222    (args LIKE 'dialout-trunk,%' OR args LIKE 'dialout-enum,%' OR args LIKE 'dialout-dundi,%') ORDER BY context,priority"; 
     3223  $results = sql( $sql_code, "getAll" ,DB_FETCHMODE_ASSOC); 
     3224  $routeseq = array(); 
     3225  foreach ($results as $entry) { 
     3226    $pos1 = strpos($entry['trunk'],',')+1; 
     3227    $routeseq[$entry['route']][] = substr($entry['trunk'],$pos1,strpos($entry['trunk'],',',$pos1)-$pos1); 
     3228  } 
     3229  $routes = array(); 
     3230  foreach ($routeseq as $key => $value) { 
     3231    $pos = array_search($trunknum, array_values(array_unique($value))); 
     3232    if ($pos !== false) { 
     3233      $routes[$key] = $pos+1; // start at 1, not 0 
     3234    } 
     3235  } 
     3236  return $routes; 
    32433237} 
    32443238