Changeset 4301

Show
Ignore:
Timestamp:
07/03/07 17:35:55 (6 years ago)
Author:
p_lindheimer
Message:

Auto Check-in of any outstanding patches

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.3/core/agi-bin/dialparties.agi

    r4275 r4301  
    2727 * to keep it from getting changed. 
    2828 */ 
    29  
    30 $config = parse_amportal_conf( "/etc/amportal.conf" ); 
    3129 
    3230require_once "phpagi.php"; 
     
    4947debug("Starting New Dialparties.agi", 1); 
    5048 
     49// Get required channels variables that used to come from amportal.conf 
     50$ampmgruser  = get_var( $AGI, "AMPMGRUSER" ); 
     51$ampmgrpass  = get_var( $AGI, "AMPMGRPASS" ); 
     52 
     53 
     54// get cwinusebusy, and just to make sure it has been set until testing has been done 
     55// and assured this channel variable is set consistantly, make sure it is valid. 
     56// 
     57// TODO: take out the checking after confirmed it is always done righto 
     58// 
     59$cwinusebusy = get_var( $AGI, "CWINUSEBUSY" ); 
     60$cwinusebusy = (trim($cwinusebusy) == "false") ? false : true; 
     61 
     62 
    5163$astman = new AGI_AsteriskManager( );  
    52 if (!$astman->connect("127.0.0.1", $config["AMPMGRUSER"] , $config["AMPMGRPASS"])) { 
     64if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 
    5365  exit (1); 
    5466} 
     
    403415        debug("Extension $extnum is available",1); 
    404416      } 
    405     } elseif ($rgmethod == "none" && $exthascw == 1 && strtoupper(trim($config['CWINUSEBUSY'])) == "YES") { 
     417    } elseif ($rgmethod == "none" && $exthascw == 1 && $cwinusebusy) { 
    406418 
    407419      $extstate = is_ext_avail($extnum); 
     
    704716function is_ext_avail( $extnum ) 
    705717{ 
    706   global $config; 
    707718  global $astman; 
    708719   
  • modules/branches/2.3/core/agi-bin/directory

    r4291 r4301  
    2424 * to keep it from getting changed. 
    2525 */ 
    26  
    27 // TODO: These are all hardcoded, means we are going to have to parse! 
    28 //       or maybe retrieve_conf can special handle them at cp time. 
    29 // 
    30  
    31 define("DIRECTORY_FILE", "/etc/asterisk/voicemail.conf"); 
    32  
    33 // where is voicemail stored? 
    34 define("VOICEMAIL_DIR", "/var/spool/asterisk/voicemail/%s/%d"); 
    35  
    36 // where shold we store logs? (fixes #1912) 
    37 define("LOG_DIR", "/var/log/asterisk/"); 
    3826 
    3927// set to 1 to say "zed" instead of "zee" 
     
    6654 
    6755include("phpagi.php"); 
     56 
     57function get_var( $agi, $value) 
     58{ 
     59  $r = $agi->get_variable( $value ); 
     60   
     61  if ($r['result'] == 1) 
     62  { 
     63    $result = $r['data']; 
     64    return $result; 
     65  } 
     66  else 
     67    return ''; 
     68} 
    6869 
    6970function output(&$var) { 
     
    321322        $match = & $directory[$digits][$i]; 
    322323         
    323         $maindirname = sprintf(VOICEMAIL_DIR, $match["context"], $match["ext"]); 
     324        $maindirname = sprintf($voicemail_dir, $match["context"], $match["ext"]); 
    324325 
    325326        if (sound_file_exists($maindirname."/greet")) { 
     
    399400$agi = new AGI; 
    400401 
    401 if (DEBUG) $logfile = fopen( LOG_DIR . "directory.log","w"); 
     402$directory_file = get_var($agi, "ASTETCDIR")."/voicemail.conf"; 
     403 
     404// where is voicemail stored? 
     405$voicemail_dir  = get_var($agi, "ASTSPOOLDIR")."/voicemail/%s/%d"; 
     406 
     407// where should we store logs? (fixes #1912) 
     408$log_dir        = get_var($agi, "ASTLOGDIR"); 
     409 
     410if (DEBUG) $logfile = fopen( $log_dir . "/directory.log","w"); 
    402411 
    403412$vmconf = array(); 
    404413$null = null; 
    405 parse_voicemailconf(DIRECTORY_FILE, $vmconf, $null); 
     414parse_voicemailconf($directory_file, $vmconf, $null); 
    406415 
    407416 
     
    415424if (!isset($vmconf[$vm_context]) && ($vm_context != "general")) { 
    416425  // we make an exception for "general" context,as it just includes other contexts 
    417   $agi->verbose("Cannot find context ".$vm_context." in ".DIRECTORY_FILE); 
     426  $agi->verbose("Cannot find context ".$vm_context." in ".$directory_file); 
    418427  exit(1); 
    419428} 
  • modules/branches/2.3/core/agi-bin/fixlocalprefix

    r4291 r4301  
    3030DIAL_TRUNK - the trunk number to use 
    3131 
    32 The list of prefixes is contained in LOCALPREFIX_FILE (defined below, defaults to /etc/asterisk/localprefixes.conf). This 
     32The list of prefixes is contained in $localprefix_file (defined below, defaults to /etc/asterisk/localprefixes.conf). This 
    3333file has the format: 
    3434 
     
    7676*/ 
    7777 
    78 // TODO: Hardcoded path, this needs removing (means we need to parse amprotal.conf or change where these are stored! 
    79 //       or maybe retrieve_conf can special handle them at install time. 
    80 // 
    81 define("LOCALPREFIX_FILE", "/etc/asterisk/localprefixes.conf"); 
    82  
    8378include("phpagi.php"); 
     79 
     80function get_var( $agi, $value) 
     81{ 
     82  $r = $agi->get_variable( $value ); 
     83   
     84  if ($r['result'] == 1) 
     85  { 
     86    $result = $r['data']; 
     87    return $result; 
     88  } 
     89  else 
     90    return ''; 
     91} 
    8492 
    8593function parse_conf($filename, &$conf, &$section) { 
     
    188196$agi = new AGI(); 
    189197 
    190 if (file_exists(LOCALPREFIX_FILE)) { 
    191   parse_conf(LOCALPREFIX_FILE, $conf, $section); 
     198$localprefix_file = get_var($agi, "ASTETCDIR")."/localprefix.conf"; 
     199 
     200if (file_exists($localprefix_file)) { 
     201  parse_conf($localprefix_file, $conf, $section); 
    192202  if (count($conf) == 0) { 
    193 //    $agi->verbose("Could not parse ".LOCALPREFIX_FILE); 
     203//    $agi->verbose("Could not parse ".$localprefix_file); 
    194204    exit(1); 
    195205  } 
    196206} else { 
    197   $agi->verbose("Could not open ".LOCALPREFIX_FILE); 
     207  $agi->verbose("Could not open ".$localprefix_file); 
    198208  exit(1); 
    199209} 
  • modules/branches/2.3/core/etc/extensions.conf

    r4279 r4301  
    290290; If the required voicemail file does not exist, then abort and go to normal voicemail behavior 
    291291; TODO: figure out which is proper file (.wav or .WAV) and maybe find a better way 
     292;       still want to find something better than 'ls' but for now, it checks either 
    292293; 
    293294exten => vmx,n,Macro(get-vmcontext,${ARG1}) 
    294 exten => vmx,n(file),System(ls /var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.wav
     295exten => vmx,n(file),System(ls ${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.[wW][aA][vV]
    295296 
    296297; Get the repeat, timeout and loop times to use if they are overriden form the global settings 
     
    308309; then we go to the timeout. Otherwise handle invalid options by looping until the limit until a valid option is played. 
    309310; 
    310 exten => vmx,n(loopstart),Read(ACTION,/var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT}) 
     311exten => vmx,n(loopstart),Read(ACTION,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT}) 
    311312exten => vmx,n,GotoIf($["${EXISTS(${ACTION})}" = "1"]?checkopt) 
    312313 
     
    591592 
    592593[macro-faxreceive] 
    593 exten => s,1,Set(FAXFILE=/var/spool/asterisk/fax/${UNIQUEID}.tif) 
     594exten => s,1,Set(FAXFILE=${ASTSPOOLDIR}/fax/${UNIQUEID}.tif) 
    594595exten => s,2,Set(EMAILADDR=${FAX_RX_EMAIL}) 
    595596exten => s,3,rxfax(${FAXFILE}) 
     
    853854exten => s,20,Set(DB(DEVICE/${CALLERID(number)}/user)=${AMPUSER}) 
    854855; create symlink from dummy device mailbox to user's mailbox 
    855 exten => s,21,System(/bin/ln -s /var/spool/asterisk/voicemail/default/${AMPUSER}/ /var/spool/asterisk/voicemail/device/${CALLERID(number)}) 
     856exten => s,21,System(/bin/ln -s ${ASTSPOOLDIR}/voicemail/default/${AMPUSER}/ ${ASTSPOOLDIR}/voicemail/device/${CALLERID(number)}) 
    856857 
    857858exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into) 
     
    877878; remove entry from user's DEVICE key 
    878879; delete the symlink to user's voicemail box 
    879 exten => s,3,System(rm -f /var/spool/asterisk/voicemail/device/${CALLERID(number)}) 
     880exten => s,3,System(rm -f ${ASTSPOOLDIR}/voicemail/device/${CALLERID(number)}) 
    880881exten => s,4,Set(DEVAMPUSER=${DB(DEVICE/${CALLERID(number)}/user)}) 
    881882exten => s,5,Set(AMPUSERDEVICES=${DB(AMPUSER/${DEVAMPUSER}/device)}) 
  • modules/branches/2.3/core/functions.inc.php

    r4226 r4301  
    5757  global $ext;  // is this the best way to pass this? 
    5858  global $version;  // this is not the best way to pass this, this should be passetd together with $engine 
     59  global $amp_conf; 
    5960 
    6061  $modulename = "core"; 
     
    384385      // modules should use $ext->addGlobal("testvar","testval"); in their module_get_config() function instead 
    385386      // I'm cheating for core functionality - do as I say, not as I do ;-)    
     387 
     388      // Auto add these globals to give access to agi scripts and other needs, unless defined in the global table. 
     389      // 
     390      $amp_conf_globals = array(  
     391        "ASTETCDIR",  
     392        "ASTMODDIR",  
     393        "ASTVARLIBDIR",  
     394        "ASTAGIDIR",  
     395        "ASTSPOOLDIR",  
     396        "ASTRUNDIR",  
     397        "ASTLOGDIR", 
     398        "CWINUSEBUSY", 
     399        "AMPMGRUSER", 
     400        "AMPMGRPASS" 
     401      ); 
     402 
    386403      $sql = "SELECT * FROM globals"; 
    387404      $globals = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 
    388405      foreach($globals as $global) { 
    389406        $ext->addGlobal($global['variable'],$global['value']); 
     407 
     408        // now if for some reason we have a variable in the global table 
     409        // that is in our $amp_conf_globals list, then remove it so we 
     410        // don't duplicate, the sql table will take precedence 
     411        // 
     412        if (array_key_exists($global['variable'],$amp_conf_globals)) { 
     413          $rm_keys = array_keys($amp_conf_globals,$global['variable']); 
     414          foreach ($rm_keys as $index) { 
     415            unset($amp_conf_globals[$index]); 
     416          } 
     417        } 
     418      } 
     419      foreach ($amp_conf_globals as $global) { 
     420        if (isset($amp_conf[$global])) { 
     421          $value = $amp_conf[$global]; 
     422          if ($value === true || $value === false) { 
     423            $value = ($value) ? 'true':'false'; 
     424          } 
     425          $ext->addGlobal($global, $value); 
     426          out("Added to globals: $global = $value"); 
     427        } 
    390428      } 
    391429       
     
    13101348    $astman->database_put("AMPUSER",$extension."/voicemail","\"".isset($voicemail)?$voicemail:''."\""); 
    13111349    $astman->database_put("AMPUSER",$extension."/device","\"".isset($device)?$device:''."\""); 
    1312     if (!isset($amp_conf['ENABLECW']) || strtolower($amp_conf['ENABLECW']) != "no") { 
     1350    if ($amp_conf['ENABLECW']) { 
    13131351      $astman->database_put("CW",$extension,"\"ENABLED\""); 
    13141352    }