Changeset 9214

Show
Ignore:
Timestamp:
03/14/10 22:08:28 (3 years ago)
Author:
p_lindheimer
Message:

closes #4138 caches destination data to be used on subsequent calls, also some tweaks towards the DAHDI support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/trunk/amp_conf/htdocs/admin/functions.inc.php

    r9132 r9214  
    13441344  global $astman; 
    13451345  global $amp_conf; 
     1346  global $chan_dahdi_loaded; 
     1347 
     1348  // determine once, subsequent calls will use this 
     1349  global $ast_with_dahdi; 
     1350 
     1351  if (isset($ast_with_dahdi)) { 
     1352    return $ast_with_dahdi; 
     1353  } 
    13461354   
    13471355  if (!$amp_conf['ZAP2DAHDICOMPAT']) { 
    1348     return false; 
     1356    $ast_with_dahdi = false; 
     1357    return $ast_with_dahdi; 
    13491358  } 
    13501359   
     
    13581367      $response = $astman->send_request('Command', array('Command' => 'module show like chan_dahdi')); 
    13591368      if (preg_match('/1 modules loaded/', $response['data'])) { 
    1360         return true; 
    1361       } 
    1362     } 
    1363   } 
    1364   return false; 
     1369        $ast_with_dahdi = true; 
     1370        $chan_dahdi_loaded = true; 
     1371        return $ast_with_dahdi; 
     1372      } else { 
     1373        $chan_dahdi_loaded = false; 
     1374      } 
     1375    } 
     1376  } 
     1377  $ast_with_dahdi = false; 
     1378  return $ast_with_dahdi; 
    13651379} 
    13661380 
     
    19741988  /* --- MODULES BEGIN --- */ 
    19751989  global $active_modules; 
    1976    
    1977   $all_destinations = array(); 
    1978   $module_hash = array(); 
     1990 
     1991  // this is global so we only populate it once and it is preserved afterwards 
     1992  global $drawselect_destinations; 
     1993  global $drawselects_module_hash; 
     1994 
    19791995  $selectHtml=''; 
    19801996  if($table){ 
     
    19821998  } 
    19831999 
    1984    
    1985   //check for module-specific destination functions 
    1986   foreach ($active_modules as $rawmod => $module) { 
    1987     $funct = strtolower($rawmod.'_destinations'); 
    1988    
    1989     //if the modulename_destinations() function exits, run it and display selections for it 
    1990     if (function_exists($funct)) { 
    1991       $destArray = $funct(); //returns an array with 'destination' and 'description', and optionally 'category' 
    1992       if (is_Array($destArray)) { 
    1993         foreach ($destArray as $dest) { 
    1994           $cat = (isset($dest['category']) ? $dest['category'] : $module['displayname']); 
    1995           $all_destinations[$cat][] = $dest; 
    1996           $module_hash[$cat] = $rawmod; 
    1997         } 
    1998       } 
    1999     } 
    2000   } 
     2000  // check for module-specific destination functions 
     2001  // if isset() then we called this once, so don't call again just use the data 
     2002  // this can result in significant savings in IVRs and other pages that present 
     2003  // multiple destinations 
     2004  // 
     2005  if (!isset($drawselect_destinations)) { 
     2006    foreach ($active_modules as $rawmod => $module) { 
     2007      $funct = strtolower($rawmod.'_destinations'); 
     2008   
     2009      //if the modulename_destinations() function exits, run it and display selections for it 
     2010      if (function_exists($funct)) { 
     2011        $destArray = $funct(); //returns an array with 'destination' and 'description', and optionally 'category' 
     2012        if (is_Array($destArray)) { 
     2013          foreach ($destArray as $dest) { 
     2014            $cat = (isset($dest['category']) ? $dest['category'] : $module['displayname']); 
     2015            $drawselect_destinations[$cat][] = $dest; 
     2016            $drawselects_module_hash[$cat] = $rawmod; 
     2017          } 
     2018        } 
     2019      } 
     2020    } 
     2021    if (!isset($drawselect_destinations)) { 
     2022      $drawselect_destinations = array(); 
     2023    } 
     2024    if (!isset($drawselects_module_hash)) { 
     2025      $drawselects_module_hash = array(); 
     2026    } 
     2027  } 
    20012028 
    20022029  $foundone = false; 
    20032030  $tabindex_needed = true; 
    2004   foreach ($all_destinations as $cat=>$destination) { 
     2031  foreach ($drawselect_destinations as $cat=>$destination) { 
    20052032    // create a select option for each destination  
    20062033    $options = ""; 
     
    20242051    // module's display since some old translation code may have stored it localy but should migrate 
    20252052    // 
    2026     bindtextdomain($module_hash[$cat],"modules/".$module_hash[$cat]."/i18n"); 
    2027     bind_textdomain_codeset($module_hash[$cat], 'utf8'); 
    2028     $label_text = dgettext($module_hash[$cat],$cat); 
     2053    bindtextdomain($drawselects_module_hash[$cat],"modules/".$drawselects_module_hash[$cat]."/i18n"); 
     2054    bind_textdomain_codeset($drawselects_module_hash[$cat], 'utf8'); 
     2055    $label_text = dgettext($drawselects_module_hash[$cat],$cat); 
    20292056    if ($label_text == $cat) { 
    20302057      $label_text = dgettext('amp',$label_text);