Changeset 13570

Show
Ignore:
Timestamp:
02/23/12 15:16:57 (1 year ago)
Author:
p_lindheimer
Message:

closes #5619 adds option to passthru from db on freepbx_settings, mainly for backup/restore functions

Files:

Legend:

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

    r13200 r13570  
    317317} 
    318318 
    319 function do_reload() { 
     319function do_reload($passthru=false) { 
    320320  global $amp_conf, $asterisk_conf, $db, $astman, $version; 
     321  $freepbx_conf =& freepbx_conf::create(); 
     322 
     323  $setting_pre_reload = $freepbx_conf->get_conf_setting('AMPMGRUSER', $passthru); 
     324  $setting_ampbin = $freepbx_conf->get_conf_setting('AMPBIN', $passthru); 
     325  $setting_post_reload = $freepbx_conf->get_conf_setting('POST_RELOAD', $passthru); 
    321326 
    322327  if (empty($version)) { 
     
    330335  $exit_val = null; 
    331336   
    332   if (isset($amp_conf["PRE_RELOAD"]) && !empty($amp_conf['PRE_RELOAD']))  { 
    333     exec( $amp_conf["PRE_RELOAD"], $output, $exit_val ); 
     337  if ($setting_pre_reload)  { 
     338    exec( $setting_pre_reload, $output, $exit_val ); 
    334339     
    335340    if ($exit_val != 0) { 
    336341      $desc = sprintf(_("Exit code was %s and output was: %s"), $exit_val, "\n\n".implode("\n",$output)); 
    337       $notify->add_error('freepbx','reload_pre_script', sprintf(_('Could not run %s script.'), $amp_conf['PRE_RELOAD']), $desc); 
     342      $notify->add_error('freepbx','reload_pre_script', sprintf(_('Could not run %s script.'), $setting_pre_reload), $desc); 
    338343       
    339344      $return['num_errors']++; 
     
    343348  } 
    344349   
    345   $retrieve = $amp_conf['AMPBIN'].'/retrieve_conf 2>&1'; 
     350  $retrieve = $setting_ampbin . '/retrieve_conf 2>&1'; 
    346351  //exec($retrieve.'&>'.$asterisk_conf['astlogdir'].'/freepbx-retrieve.log', $output, $exit_val); 
    347352  exec($retrieve, $output, $exit_val); 
     
    388393  } 
    389394   
    390   if (isset($amp_conf["POST_RELOAD"]) && !empty($amp_conf['POST_RELOAD']))  { 
    391     exec( $amp_conf["POST_RELOAD"], $output, $exit_val ); 
     395  if ($setting_pre_reload)  { 
     396    exec( $setting_pre_reload, $output, $exit_val ); 
    392397     
    393398    if ($exit_val != 0) { 
    394399      $desc = sprintf(_("Exit code was %s and output was: %s"), $exit_val, "\n\n".implode("\n",$output)); 
    395       $notify->add_error('freepbx','reload_post_script', sprintf(_('Could not run %s script.'), 'POST_RELOAD'), $desc); 
     400      $notify->add_error('freepbx','reload_post_script', sprintf(_('Could not run %s script.'), $setting_pre_reload), $desc); 
    396401       
    397402      $return['num_errors']++; 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/libraries/freepbx_conf.class.php

    r12810 r13570  
    522522   * 
    523523   * @param string  The setting to fetch. 
     524   * @param boolean Optional forces the actual database variable to be fetched 
    524525   * @return mixed  returns the value of the setting, or boolean false if the 
    525526   *                setting does not exist. Since configuration booleans are 
     
    528529   *                not exist. 
    529530   */ 
    530   function get_conf_setting($keyword) { 
    531     if (isset($this->db_conf_store[$keyword])) { 
     531  function get_conf_setting($keyword, $passthru=false) { 
     532    if ($passthru) { 
     533      // This is a special case situation, do I need to confirm if the setting 
     534      // actually exists so I can return a boolean false if not? 
     535      // 
     536      global $db; 
     537      $sql = "SELECT `value` FROM freepbx_settings WHERE `keyword` = '$keyword'";  
     538      $value = $db->getOne($sql);  
     539      if (isset($this->db_conf_store[$keyword])) { 
     540        $this->db_conf_store[$keyword]['value'] = $value; 
     541      } 
     542      return $value; 
     543    } elseif (isset($this->db_conf_store[$keyword])) { 
    532544      return $this->db_conf_store[$keyword]['value']; 
    533545    } else {