Changeset 7751
- Timestamp:
- 05/26/09 14:42:42 (3 years ago)
- Files:
-
- modules/branches/2.6/core/agi-bin/dialparties.agi (modified) (4 diffs)
- modules/branches/2.6/core/functions.inc.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.6/core/agi-bin/dialparties.agi
r7713 r7751 58 58 $cfignore = strtoupper(trim($cfignore)); 59 59 60 $astman = new AGI_AsteriskManager( ); 61 if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 62 exit (1); 60 $ast_ge_16 = version_compare($ast_version, "1.6", "ge"); 61 $has_extension_state = (get_var( $AGI, "HAS_EXTENSION_STATE" ) || $ast_ge_16); 62 // If we are 1.6 then we have the EXTENSION_STATE() function and don't need to use the manager 63 // 64 if (!$has_extension_state) { 65 $astman = new AGI_AsteriskManager( ); 66 if (!$astman->connect("127.0.0.1", $ampmgruser , $ampmgrpass)) { 67 exit (1); 68 } 63 69 } 64 70 … … 645 651 // Asterisk 1.6 uses , instead of | and 1.4 can't recieve a , in the ds. 646 652 // 647 if ( version_compare($ast_version, "1.6", "ge")) {653 if ($ast_ge_16) { 648 654 $ds_seperator = ','; 649 655 } else { … … 695 701 } 696 702 697 $astman->disconnect(); 703 if (!$has_extension_state) { 704 $astman->disconnect(); 705 } 698 706 699 707 // EOF dialparties.agi … … 767 775 function is_ext_avail( $extnum ) { 768 776 global $astman; 769 770 $status = $astman->ExtensionState( $extnum, 'from-internal' ); 771 772 $status = $status['Status']; 773 debug("ExtensionState: $status", 4); 777 global $AGI; 778 global $has_extension_state; 779 780 if ($has_extension_state) { 781 $extstate_result = get_var( $AGI, "EXTENSION_STATE($extnum)" ); 782 switch ($extstate_result) { 783 case "NOT_INUSE": 784 $status = 0; 785 break; 786 case "INUSE": 787 $status = 1; 788 break; 789 case "BUSY": 790 $status = 2; 791 break; 792 case "UNAVAILABLE": 793 $status = 4; 794 break; 795 case "RINGING": 796 $status = 8; 797 break; 798 case "RINGINUSE": 799 $status = 9; 800 break; 801 case "HOLDINUSE": 802 $status = 17; 803 break; 804 case "ONHOLD": 805 $status = 16; 806 break; 807 case "UNKNOWN": 808 default: 809 $status = 4; 810 } 811 debug("EXTENSION_STATE: $status ($extstate_result)", 1); 812 } else { 813 $status = $astman->ExtensionState( $extnum, 'from-internal' ); 814 $status = $status['Status']; 815 debug("ExtensionState: $status", 1); 816 } 774 817 return $status; 775 818 } modules/branches/2.6/core/functions.inc.php
r7741 r7751 658 658 global $core_conf; 659 659 global $chan_dahdi; 660 global $astman;; 660 661 661 662 $modulename = "core"; … … 1321 1322 $ext->addGlobal('CALLINGPRES_35', 'prohib'); 1322 1323 $ext->addGlobal('CALLINGPRES_67', 'unavailable'); 1324 } 1325 1326 // This checks if we have func_extstate loaded, if so we set the global which dialparties 1327 // can use (and any other AGI script) to determine that this function exists and not connect 1328 // to the manager to get the information 1329 // 1330 if (version_compare($version, '1.4', 'ge') && version_compare($version, '1.6', 'lt')) { 1331 $response = $astman->send_request('Command', array('Command' => 'module show like func_extstate')); 1332 if (preg_match('/1 modules loaded/', $response['data'])) { 1333 $ext->addGlobal('HAS_EXTENSION_STATE', 'TRUE'); 1334 } 1323 1335 } 1324 1336
