Changeset 4301
- Timestamp:
- 07/03/07 14:35:55 (2 years ago)
- Files:
-
- modules/branches/2.3/core/agi-bin/dialparties.agi (modified) (4 diffs)
- modules/branches/2.3/core/agi-bin/directory (modified) (5 diffs)
- modules/branches/2.3/core/agi-bin/fixlocalprefix (modified) (3 diffs)
- modules/branches/2.3/core/etc/extensions.conf (modified) (5 diffs)
- modules/branches/2.3/core/functions.inc.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.3/core/agi-bin/dialparties.agi
r4275 r4301 27 27 * to keep it from getting changed. 28 28 */ 29 30 $config = parse_amportal_conf( "/etc/amportal.conf" );31 29 32 30 require_once "phpagi.php"; … … 49 47 debug("Starting New Dialparties.agi", 1); 50 48 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 51 63 $astman = new AGI_AsteriskManager( ); 52 if (!$astman->connect("127.0.0.1", $ config["AMPMGRUSER"] , $config["AMPMGRPASS"])) {64 if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 53 65 exit (1); 54 66 } … … 403 415 debug("Extension $extnum is available",1); 404 416 } 405 } elseif ($rgmethod == "none" && $exthascw == 1 && strtoupper(trim($config['CWINUSEBUSY'])) == "YES") {417 } elseif ($rgmethod == "none" && $exthascw == 1 && $cwinusebusy) { 406 418 407 419 $extstate = is_ext_avail($extnum); … … 704 716 function is_ext_avail( $extnum ) 705 717 { 706 global $config;707 718 global $astman; 708 719 modules/branches/2.3/core/agi-bin/directory
r4291 r4301 24 24 * to keep it from getting changed. 25 25 */ 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/");38 26 39 27 // set to 1 to say "zed" instead of "zee" … … 66 54 67 55 include("phpagi.php"); 56 57 function 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 } 68 69 69 70 function output(&$var) { … … 321 322 $match = & $directory[$digits][$i]; 322 323 323 $maindirname = sprintf( VOICEMAIL_DIR, $match["context"], $match["ext"]);324 $maindirname = sprintf($voicemail_dir, $match["context"], $match["ext"]); 324 325 325 326 if (sound_file_exists($maindirname."/greet")) { … … 399 400 $agi = new AGI; 400 401 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 410 if (DEBUG) $logfile = fopen( $log_dir . "/directory.log","w"); 402 411 403 412 $vmconf = array(); 404 413 $null = null; 405 parse_voicemailconf( DIRECTORY_FILE, $vmconf, $null);414 parse_voicemailconf($directory_file, $vmconf, $null); 406 415 407 416 … … 415 424 if (!isset($vmconf[$vm_context]) && ($vm_context != "general")) { 416 425 // 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); 418 427 exit(1); 419 428 } modules/branches/2.3/core/agi-bin/fixlocalprefix
r4291 r4301 30 30 DIAL_TRUNK - the trunk number to use 31 31 32 The list of prefixes is contained in LOCALPREFIX_FILE(defined below, defaults to /etc/asterisk/localprefixes.conf). This32 The list of prefixes is contained in $localprefix_file (defined below, defaults to /etc/asterisk/localprefixes.conf). This 33 33 file has the format: 34 34 … … 76 76 */ 77 77 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 83 78 include("phpagi.php"); 79 80 function 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 } 84 92 85 93 function parse_conf($filename, &$conf, &$section) { … … 188 196 $agi = new AGI(); 189 197 190 if (file_exists(LOCALPREFIX_FILE)) { 191 parse_conf(LOCALPREFIX_FILE, $conf, $section); 198 $localprefix_file = get_var($agi, "ASTETCDIR")."/localprefix.conf"; 199 200 if (file_exists($localprefix_file)) { 201 parse_conf($localprefix_file, $conf, $section); 192 202 if (count($conf) == 0) { 193 // $agi->verbose("Could not parse ". LOCALPREFIX_FILE);203 // $agi->verbose("Could not parse ".$localprefix_file); 194 204 exit(1); 195 205 } 196 206 } else { 197 $agi->verbose("Could not open ". LOCALPREFIX_FILE);207 $agi->verbose("Could not open ".$localprefix_file); 198 208 exit(1); 199 209 } modules/branches/2.3/core/etc/extensions.conf
r4279 r4301 290 290 ; If the required voicemail file does not exist, then abort and go to normal voicemail behavior 291 291 ; 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 292 293 ; 293 294 exten => vmx,n,Macro(get-vmcontext,${ARG1}) 294 exten => vmx,n(file),System(ls /var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.wav)295 exten => vmx,n(file),System(ls ${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE}.[wW][aA][vV]) 295 296 296 297 ; Get the repeat, timeout and loop times to use if they are overriden form the global settings … … 308 309 ; then we go to the timeout. Otherwise handle invalid options by looping until the limit until a valid option is played. 309 310 ; 310 exten => vmx,n(loopstart),Read(ACTION, /var/spool/asterisk/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT})311 exten => vmx,n(loopstart),Read(ACTION,${ASTSPOOLDIR}/voicemail/${VMCONTEXT}/${ARG1}/${MODE},1,skip,${VMX_REPEAT},${VMX_TIMEOUT}) 311 312 exten => vmx,n,GotoIf($["${EXISTS(${ACTION})}" = "1"]?checkopt) 312 313 … … 591 592 592 593 [macro-faxreceive] 593 exten => s,1,Set(FAXFILE= /var/spool/asterisk/fax/${UNIQUEID}.tif)594 exten => s,1,Set(FAXFILE=${ASTSPOOLDIR}/fax/${UNIQUEID}.tif) 594 595 exten => s,2,Set(EMAILADDR=${FAX_RX_EMAIL}) 595 596 exten => s,3,rxfax(${FAXFILE}) … … 853 854 exten => s,20,Set(DB(DEVICE/${CALLERID(number)}/user)=${AMPUSER}) 854 855 ; 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)})856 exten => s,21,System(/bin/ln -s ${ASTSPOOLDIR}/voicemail/default/${AMPUSER}/ ${ASTSPOOLDIR}/voicemail/device/${CALLERID(number)}) 856 857 857 858 exten => s-FIXED,1,NoOp(Device is FIXED and cannot be logged into) … … 877 878 ; remove entry from user's DEVICE key 878 879 ; delete the symlink to user's voicemail box 879 exten => s,3,System(rm -f /var/spool/asterisk/voicemail/device/${CALLERID(number)})880 exten => s,3,System(rm -f ${ASTSPOOLDIR}/voicemail/device/${CALLERID(number)}) 880 881 exten => s,4,Set(DEVAMPUSER=${DB(DEVICE/${CALLERID(number)}/user)}) 881 882 exten => s,5,Set(AMPUSERDEVICES=${DB(AMPUSER/${DEVAMPUSER}/device)}) modules/branches/2.3/core/functions.inc.php
r4226 r4301 57 57 global $ext; // is this the best way to pass this? 58 58 global $version; // this is not the best way to pass this, this should be passetd together with $engine 59 global $amp_conf; 59 60 60 61 $modulename = "core"; … … 384 385 // modules should use $ext->addGlobal("testvar","testval"); in their module_get_config() function instead 385 386 // 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 386 403 $sql = "SELECT * FROM globals"; 387 404 $globals = sql($sql,"getAll",DB_FETCHMODE_ASSOC); 388 405 foreach($globals as $global) { 389 406 $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 } 390 428 } 391 429 … … 1310 1348 $astman->database_put("AMPUSER",$extension."/voicemail","\"".isset($voicemail)?$voicemail:''."\""); 1311 1349 $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']) { 1313 1351 $astman->database_put("CW",$extension,"\"ENABLED\""); 1314 1352 }
