Changeset 9217
- Timestamp:
- 03/15/10 01:38:42 (3 years ago)
- Files:
-
- modules/branches/2.8/core/functions.inc.php (modified) (19 diffs)
- modules/branches/2.8/core/page.trunks.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.8/core/functions.inc.php
r9210 r9217 73 73 break; 74 74 case 'chan_dahdi_additional.conf': 75 return $this->generate_zapata_additional($version); 75 if (ast_with_dahdi()) { 76 return $this->generate_zapata_additional($version); 77 } else { 78 return $this->generate_zapata_additional($version, 'dahdi'); 79 } 76 80 break; 77 81 case 'zapata_additional.conf': … … 515 519 } 516 520 517 function generate_zapata_additional($ast_version ) {521 function generate_zapata_additional($ast_version, $table_name = 'zap') { 518 522 global $db; 519 520 $table_name = "zap";521 523 522 524 $additional = ""; … … 772 774 global $core_conf; 773 775 global $chan_dahdi; 774 global $astman;; 776 global $chan_dahdi_loaded; 777 global $astman; 775 778 776 779 $modulename = "core"; … … 1222 1225 } 1223 1226 1224 // Now create macro-from-zaptel-nnn for each defined channel to route it to the DID routing1227 // Now create macro-from-zaptel-nnn or macro-from-dahdi-nnn for each defined channel to route it to the DID routing 1225 1228 // Send it to from-trunk so it is handled as other dids would be handled. 1226 1229 // 1230 // to this point we have both zap and dahdi configuration options. At generation though they can't co-exists. If compatibility 1231 // mode then it's still from-zaptel, otherwise it is which ever is present. We cant use ast_with_dahdi() (chan_dadi) because 1232 // it is for detection with compatibility mode. We need to actually determine if chan_dahdi is present or not at this point 1233 // 1234 if (!isset($chan_dahdi_loaded) { 1235 if ($ast_ge_14 && isset($astman) && $astman->connected() { 1236 $response = $astman->send_request('Command', array('Command' => 'module show like chan_dahdi')); 1237 $chan_dahdi_loaded = (preg_match('/1 modules loaded/', $response['data']) > 0); 1238 } 1239 } 1240 $context_type = $chan_dahdi_loaded ? 'dahdi' : 'zaptel'; 1227 1241 foreach (core_zapchandids_list() as $row) { 1228 1242 $channel = $row['channel']; 1229 1243 $did = $row['did']; 1230 1244 1231 $ zap_context = "macro-from-zaptel-{$channel}";1232 $ext->add($zap_context, 's', '', new ext_noop('Entering '.$ zap_context.' with DID = ${DID} and setting to: '.$did));1245 $this_context = "macro-from-$context_type-$channel"; 1246 $ext->add($zap_context, 's', '', new ext_noop('Entering '.$this_context.' with DID = ${DID} and setting to: '.$did)); 1233 1247 $ext->add($zap_context, 's', '', new ext_setvar('__FROM_DID',$did)); 1234 1248 $ext->add($zap_context, 's', '', new ext_goto('1',$did,'from-trunk')); … … 2401 2415 $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-zaptel-${CHAN}')); 2402 2416 $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-pstn')); 2417 2418 2419 if (!$chan_dahdi) { 2420 $context = 'from-dahdi'; 2421 $exten = '_X.'; 2422 2423 $ext->add($context, $exten, '', new ext_set('DID', '${EXTEN}')); 2424 $ext->add($context, $exten, '', new ext_goto(1, 's')); 2425 2426 $exten = 's'; 2427 $ext->add($context, $exten, '', new ext_noop('Entering from-dahdi with DID == ${DID}')); 2428 // Some trunks _require_ a RINGING be sent before an Answer. 2429 $ext->add($context, $exten, '', new ext_ringing()); 2430 // If ($did == "") { $did = "s"; } 2431 $ext->add($context, $exten, '', new ext_set('DID', '${IF($["${DID}"= ""]?s:${DID})}')); 2432 $ext->add($context, $exten, '', new ext_noop('DID is now ${DID}')); 2433 $ext->add($context, $exten, '', new ext_gotoif('$["${CHANNEL:0:5}"="DAHDI"]', 'dahdiok', 'notdahdi')); 2434 $ext->add($context, $exten, 'notdahdi', new ext_goto('1', '${DID}', 'from-pstn')); 2435 // If there's no ext-did,s,1, that means there's not a no did/no cid route. Hangup. 2436 $ext->add($context, $exten, '', new ext_macro('Hangupcall', 'dummy')); 2437 $ext->add($context, $exten, 'dahdiok', new ext_noop('Is a Zaptel Channel')); 2438 $ext->add($context, $exten, '', new ext_set('CHAN', '${CHANNEL:6}')); 2439 $ext->add($context, $exten, '', new ext_set('CHAN', '${CUT(CHAN,-,1)}')); 2440 $ext->add($context, $exten, '', new ext_macro('from-dahdi-${CHAN}', '${DID},1')); 2441 // If nothing there, then treat it as a DID 2442 $ext->add($context, $exten, '', new ext_noop('Returned from Macro from-dahdi-${CHAN}')); 2443 $ext->add($context, $exten, '', new ext_goto(1, '${DID}', 'from-pstn')); 2444 } 2403 2445 2404 2446 /* … … 2793 2835 $ext->add($mcontext,$exten,'checkrecord', new ext_macro('record-enable','${EXTTOCALL},IN')); 2794 2836 2795 if ($ amp_conf['USEDIALONE'] && $has_extension_state) {2837 if ($has_extension_state) { 2796 2838 $ext->add($mcontext,$exten,'macrodial', new ext_macro('dial-one','${RT},${DIAL_OPTIONS},${EXTTOCALL}')); 2797 2839 } else { … … 2859 2901 $ext->add($mcontext,$exten,'', new ext_set("CFBEXT", '${DB(CFB/${EXTTOCALL})}')); 2860 2902 $ext->add($mcontext,$exten,'', new ext_set("CWI_TMP", '${CWIGNORE}')); 2861 if ($ amp_conf['USEDIALONE'] && $has_extension_state) {2903 if ($has_extension_state) { 2862 2904 $ext->add($mcontext,$exten,'macrodial', new ext_macro('dial-one','${RT},${DIAL_OPTIONS},${EXTTOCALL}')); 2863 2905 } else { … … 2938 2980 un-documented USEMACRODIALONE = true flag. 2939 2981 */ 2940 if ($ amp_conf['USEDIALONE'] && $has_extension_state) {2982 if ($has_extension_state) { 2941 2983 2942 2984 $mcontext = 'macro-dial-one'; … … 3279 3321 case "SIP": 3280 3322 case "ZAP": 3323 case "DAHDI": 3281 3324 $sql .= " WHERE tech = '".strtolower($tech)."'"; 3282 3325 break; … … 3342 3385 } 3343 3386 //unless defined, $dial is TECH/id 3344 if ( $dial == '') {3345 //zap is an exception3346 if ( strtolower($tech) == "zap") {3347 $ zapchan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel'];3348 $dial = 'ZAP/'.$zapchan;3387 if ($dial == '') { 3388 //zap, dahdi are exceptions 3389 if (strtolower($tech) == "zap" || strtolower($tech) == 'dahdi') { 3390 $thischan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 3391 $dial = strtoupper($tech).'/'.$thischan; 3349 3392 } else { 3350 3393 $dial = strtoupper($tech)."/".$id; … … 3821 3864 } 3822 3865 3866 function core_devices_adddahdi($account) { 3867 global $db; 3868 global $currentFile; 3869 3870 foreach ($_REQUEST as $req=>$data) { 3871 if ( substr($req, 0, 8) == 'devinfo_' ) { 3872 $keyword = substr($req, 8); 3873 if ( $keyword == 'dial' && $data == '' ) { 3874 $dahdichan = $_REQUEST['devinfo_channel'] != '' ? $_REQUEST['devinfo_channel'] : $_REQUEST['channel']; 3875 $dahdifields[] = array($account, $keyword, 'DAHDI/'.$dahdichan); 3876 } elseif ($keyword == 'mailbox' && $data == '') { 3877 $dahdifields[] = array($account,'mailbox',$account.'@device'); 3878 } else { 3879 $dahdifields[] = array($account, $keyword, $data); 3880 } 3881 } 3882 } 3883 3884 if ( !is_array($dahdifields) ) { // left for compatibilty....lord knows why ! 3885 $dahdifields = array( 3886 array($account,'context',$db->escapeSimple(($_REQUEST['context'])?$_REQUEST['context']:'from-internal')), 3887 array($account,'mailbox',$db->escapeSimple(($_REQUEST['mailbox'])?$_REQUEST['mailbox']:$account.'@device')), 3888 array($account,'immediate',$db->escapeSimple(($_REQUEST['immediate'])?$_REQUEST['immediate']:'no')), 3889 array($account,'signalling',$db->escapeSimple(($_REQUEST['signalling'])?$_REQUEST['signalling']:'fxo_ks')), 3890 array($account,'echocancel',$db->escapeSimple(($_REQUEST['echocancel'])?$_REQUEST['echocancel']:'yes')), 3891 array($account,'echocancelwhenbridged',$db->escapeSimple(($_REQUEST['echocancelwhenbridged'])?$_REQUEST['echocancelwhenbridged']:'no')), 3892 array($account,'immediate',$db->escapeSimple(($_REQUEST['immediate'])?$_REQUEST['immediate']:'no')), 3893 array($account,'echotraining',$db->escapeSimple(($_REQUEST['echotraining'])?$_REQUEST['echotraining']:'800')), 3894 array($account,'busydetect',$db->escapeSimple(($_REQUEST['busydetect'])?$_REQUEST['busydetect']:'no')), 3895 array($account,'busycount',$db->escapeSimple(($_REQUEST['busycount'])?$_REQUEST['busycount']:'7')), 3896 array($account,'callprogress',$db->escapeSimple(($_REQUEST['callprogress'])?$_REQUEST['callprogress']:'no')), 3897 array($account,'accountcode',$db->escapeSimple((isset($_REQUEST['accountcode']))?$_REQUEST['accountcode']:'')), 3898 array($account,'callgroup',$db->escapeSimple((isset($_REQUEST['callgroup']))?$_REQUEST['callgroup']:'')), 3899 array($account,'pickupgroup',$db->escapeSimple((isset($_REQUEST['pickupgroup']))?$_REQUEST['pickupgroup']:'')), 3900 array($account,'channel',$db->escapeSimple(($_REQUEST['channel'])?$_REQUEST['channel']:'')) 3901 ); 3902 } 3903 3904 // Very bad 3905 $dahdifields[] = array($account,'account',$db->escapeSimple($account)); 3906 $dahdifields[] = array($account,'callerid',$db->escapeSimple(($_REQUEST['description'])?$_REQUEST['description']." <".$account.'>':'device'." <".$account.'>')); 3907 3908 // Where is this in the interface ?????? 3909 $dahdifields[] = array($account,'record_in',$db->escapeSimple(($_REQUEST['record_in'])?$_REQUEST['record_in']:'On-Demand')); 3910 $dahdifields[] = array($account,'record_out',$db->escapeSimple(($_REQUEST['record_out'])?$_REQUEST['record_out']:'On-Demand')); 3911 3912 $compiled = $db->prepare('INSERT INTO dahdi (id, keyword, data) values (?,?,?)'); 3913 $result = $db->executeMultiple($compiled,$dahdifields); 3914 if(DB::IsError($result)) { 3915 die_freepbx($result->getMessage()."<br><br>error adding to DAHDI table"); 3916 } 3917 } 3918 3823 3919 function core_devices_delzap($account) { 3824 3920 global $db; … … 3832 3928 } 3833 3929 3930 function core_devices_deldahdi($account) { 3931 global $db; 3932 global $currentFile; 3933 3934 $sql = "DELETE FROM dahdi WHERE id = '$account'"; 3935 $result = $db->query($sql); 3936 if(DB::IsError($result)) { 3937 die_freepbx($result->getMessage().$sql); 3938 } 3939 } 3940 3834 3941 function core_devices_getzap($account) { 3835 3942 global $db; 3836 3943 $sql = "SELECT keyword,data FROM zap WHERE id = '$account'"; 3944 $results = $db->getAssoc($sql); 3945 if(DB::IsError($results)) { 3946 $results = null; 3947 } 3948 return $results; 3949 } 3950 3951 function core_devices_getdahdi($account) { 3952 global $db; 3953 $sql = "SELECT keyword,data FROM dahdi WHERE id = '$account'"; 3837 3954 $results = $db->getAssoc($sql); 3838 3955 if(DB::IsError($results)) { … … 4665 4782 global $db; 4666 4783 4667 $values = array();4668 4784 $rules_arr = array(); 4669 4785 $i = 1; 4670 4786 foreach ($dialrules as $rule) { 4671 4787 $rules_arr[] = array($db->escapeSimple($rule),$i); 4672 $values["rule".$i++] = $rule; 4673 } 4674 4788 $i++; 4789 } 4675 4790 sql("DELETE FROM `trunks_dialpatterns` WHERE `trunkid` = $trunknum"); 4676 4791 $compiled = $db->prepare("INSERT INTO `trunks_dialpatterns` (trunkid, rule, seq) VALUES ($trunknum,?,?)"); … … 4693 4808 $rule_hash['trunk-'.$pattern['trunkid']]['rule'.$rule_num++] = $pattern['rule']; 4694 4809 } 4695 4696 4810 return $rule_hash; 4697 4811 } 4698 4699 /* DEPRECATED - SHOULD NO LONGER BE USED, generated from core_conf in retrieve_conf4700 *4701 function core_trunks_writeDialRulesFile($conf) {4702 global $amp_conf;4703 $localPrefixFile = $amp_conf['ASTETCDIR']."/localprefixes.conf";4704 4705 $fd = fopen($localPrefixFile,"w");4706 foreach ($conf as $section=>$values) {4707 fwrite($fd, "[".$section."]\n");4708 foreach ($values as $key=>$value) {4709 fwrite($fd, $key."=".$value."\n");4710 }4711 fwrite($fd, "\n");4712 }4713 fclose($fd);4714 }4715 */4716 4812 4717 4813 /* THIS HAS BEEN DEPRECATED BUT WILL REMAIN IN FOR A FEW RELEASES */ … … 4761 4857 $tech = core_trunks_getTrunkTech($trunknum); 4762 4858 4763 if ($tech == "zap" || $tech == "") return ""; // zap has no details4859 if ($tech == "zap" || $tech =="dahdi" || $tech == "") return ""; // zap has no details 4764 4860 4765 4861 $results = sql("SELECT keyword,data FROM $tech WHERE `id` = 'tr-peer-$trunknum' ORDER BY flags, keyword DESC","getAll"); … … 4786 4882 $tech = core_trunks_getTrunkTech($trunknum); 4787 4883 4788 if ($tech == "zap" || $tech == "") return ""; // zap has no details4884 if ($tech == "zap" || $tech =="dahdi" || $tech == "") return ""; // zap has no details 4789 4885 4790 4886 $results = sql("SELECT keyword,data FROM $tech WHERE `id` = 'tr-user-$trunknum' ORDER BY flags, keyword DESC","getAll"); … … 4805 4901 $tech = core_trunks_getTrunkTech($trunknum); 4806 4902 4807 if ($tech == "zap" || $tech == " ") return ""; // zap has no register4903 if ($tech == "zap" || $tech == "dahdi" || $tech == "") return ""; // zap has no register 4808 4904 4809 4905 $results = sql("SELECT `keyword`, `data` FROM $tech WHERE `id` = 'tr-reg-$trunknum'","getAll"); … … 5678 5774 $currentcomponent->addgeneralarrayitem('devtechs', 'zap', $tmparr); 5679 5775 unset($tmparr); 5776 5777 // dahdi 5778 $tmparr = array(); 5779 $tmparr['channel'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel); 5780 $tmparr['context'] = array('value' => 'from-internal', 'level' => 1); 5781 $tmparr['immediate'] = array('value' => 'no', 'level' => 1); 5782 $tmparr['signalling'] = array('value' => 'fxo_ks', 'level' => 1); 5783 $tmparr['echocancel'] = array('value' => 'yes', 'level' => 1); 5784 $tmparr['echocancelwhenbridged'] = array('value' => 'no', 'level' => 1); 5785 $tmparr['echotraining'] = array('value' => '800', 'level' => 1); 5786 $tmparr['busydetect'] = array('value' => 'no', 'level' => 1); 5787 $tmparr['busycount'] = array('value' => '7', 'level' => 1); 5788 $tmparr['callprogress'] = array('value' => 'no', 'level' => 1); 5789 $tmparr['dial'] = array('value' => '', 'level' => 1); 5790 $tmparr['accountcode'] = array('value' => '', 'level' => 1); 5791 $tmparr['callgroup'] = array('value' => '', 'level' => 1); 5792 $tmparr['pickupgroup'] = array('value' => '', 'level' => 1); 5793 $tmparr['mailbox'] = array('value' => '', 'level' => 1); 5794 $currentcomponent->addgeneralarrayitem('devtechs', 'dahdi', $tmparr); 5795 unset($tmparr); 5680 5796 5681 5797 // iax2 … … 5734 5850 $currentcomponent->addoptlistitem('devicelist', 'iax2_generic', _("Generic IAX2 Device")); 5735 5851 $currentcomponent->addoptlistitem('devicelist', 'zap_generic', _("Generic ZAP Device")); 5852 if (!ast_with_dahdi()) { 5853 $currentcomponent->addoptlistitem('devicelist', 'dahdi_generic', _("Generic DAHDI Device")); 5854 } 5736 5855 $currentcomponent->addoptlistitem('devicelist', 'custom_custom', _("Other (Custom) Device")); 5737 5856 } modules/branches/2.8/core/page.trunks.php
r9210 r9217 213 213 <?php 214 214 $baseURL = $_SERVER['PHP_SELF'].'?display='.urlencode($display).'&'; 215 $trunks = array( 216 array('url'=> $baseURL.'tech=ZAP', 'tlabel' => _("Add Zap Trunk").(ast_with_dahdi()?" ("._("DAHDI compatibility mode").")":"" )), 217 array('url'=> $baseURL.'tech=SIP', 'tlabel' => _("Add SIP Trunk")), 218 array('url'=> $baseURL.'tech=IAX2', 'tlabel' => _("Add IAX2 Trunk")), 219 array('url'=> $baseURL.'tech=ENUM', 'tlabel' => _("Add ENUM Trunk")), 220 array('url'=> $baseURL.'tech=DUNDI', 'tlabel' => _("Add DUNDi Trunk")), 221 array('url'=> $baseURL.'tech=CUSTOM', 'tlabel' => _("Add Custom Trunk")), 222 ); 215 $trunks[] = array('url'=> $baseURL.'tech=SIP', 'tlabel' => _("Add SIP Trunk")); 216 if (!ast_with_dahdi()) { 217 $trunks[] = array('url'=> $baseURL.'tech=DAHDI', 'tlabel' => _("Add DAHDI Trunk")); 218 } 219 $trunks[] = array('url'=> $baseURL.'tech=ZAP', 'tlabel' => _("Add Zap Trunk").(ast_with_dahdi()?" ("._("DAHDI compatibility mode").")":"" )); 220 $trunks[] = array('url'=> $baseURL.'tech=IAX2', 'tlabel' => _("Add IAX2 Trunk")); 221 $trunks[] = array('url'=> $baseURL.'tech=ENUM', 'tlabel' => _("Add ENUM Trunk")); 222 $trunks[] = array('url'=> $baseURL.'tech=DUNDI', 'tlabel' => _("Add DUNDi Trunk")); 223 $trunks[] = array('url'=> $baseURL.'tech=CUSTOM', 'tlabel' => _("Add Custom Trunk")); 223 224 foreach ($trunks as $trunk) { 224 225 $label = '<span><img width="16" height="16" border="0" title="'.$trunk['tlabel'].'" alt="" src="images/core_add.png"/> '.$trunk['tlabel'].'</span>'; … … 313 314 $dialoutprefix = ""; 314 315 315 if ($tech == "zap") {316 $channelid = "g0";316 if ($tech == 'zap' || $tech == 'dahdi') { 317 $channelid = 'g0'; 317 318 } else { 318 $channelid = "";319 $channelid = ''; 319 320 } 320 321 … … 364 365 <tr> 365 366 <td> 366 <a href=# class="info"><?php echo _("Trunk Description")?><span><br><?php echo _("Descriptive Name for this Trunk")?><br><br></span></a>:367 <a href=# class="info"><?php echo _("Trunk Name")?><span><br><?php echo _("Descriptive Name for this Trunk")?><br><br></span></a>: 367 368 </td><td> 368 369 <input type="text" size="30" name="trunk_name" value="<?php echo $trunk_name;?>" tabindex="<?php echo ++$tabindex;?>"/> … … 463 464 <a href=# class="info"><?php echo _("Dial Rules Wizards")?><span> 464 465 <strong><?php echo _("Always dial with prefix")?></strong> <?php echo _("is useful for VoIP trunks, where if a number is dialed as \"5551234\", it can be converted to \"16135551234\".")?><br> 465 <strong><?php echo _("Remove prefix from local numbers")?></strong> <?php echo _("is useful for ZAP trunks, where if a local number is dialed as \"6135551234\", it can be converted to \"555-1234\".")?><br>466 <strong><?php echo _("Remove prefix from local numbers")?></strong> <?php echo _("is useful for ZAP and DAHDI trunks, where if a local number is dialed as \"6135551234\", it can be converted to \"555-1234\".")?><br> 466 467 <strong><?php echo _("Lookup numbers for local trunk")?></strong> <?php echo _("This looks up your local number on www.localcallingguide.com (NA-only), and sets up so you can dial either 7 or 10 digits (regardless of what your PSTN is) on a local trunk (where you have to dial 1+area code for long distance, but only 5551234 (7-digit dialing) or 6135551234 (10-digit dialing) for local calls")?><br> 467 468 </span></a>: … … 695 696 <tr> 696 697 <td> 697 <a href=# class="info"><?php echo _("Zap Identifier (trunk name)")?><span><br><?php echo _("ZAP channels are referenced either by a group number or channel number (which is defined in zapata.conf). <br><br>The default setting is <b>g0</b> (group zero).")?><br><br></span></a>: 698 <a href=# class="info"><?php echo _("Zap Identifier")?><span><br><?php echo _("ZAP channels are referenced either by a group number or channel number (which is defined in zapata.conf). <br><br>The default setting is <b>g0</b> (group zero).")?><br><br></span></a>: 699 </td><td> 700 <input type="text" size="8" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>" tabindex="<?php echo ++$tabindex;?>"/> 701 <input type="hidden" size="14" name="usercontext" value="notneeded"/> 702 </td> 703 </tr> 704 <?php 705 break; 706 case "dahdi": 707 ?> 708 <tr> 709 <td> 710 <a href=# class="info"><?php echo _("DAHDI Identifier")?><span><br><?php echo _("DAHDI channels are referenced either by a group number or channel number (which is defined in chan_dahdi.conf). <br><br>The default setting is <b>g0</b> (group zero).")?><br><br></span></a>: 698 711 </td><td> 699 712 <input type="text" size="8" name="channelid" value="<?php echo htmlspecialchars($channelid) ?>" tabindex="<?php echo ++$tabindex;?>"/>
