Adhoc Extension States Not Being Checked

I am currently running FreePBX with Asterisk 1.4.9 I’ve applied the patch that fixes the hints problems where after a transfer, extensions stay on hold. All is fine with that now.

My new problem is that when using FreePBX in deviceanduser mode Asterisk does not seem to check the state of the extension the user is logged into and simply passes the call on regardless. This has an effect of forcing call waiting to be enabled which we do not want.

I thought this may be a FreePBX issue but after looking through dialparties.agi, I found the following piece of code which looks like asterisk supports being logged into multiple devices:

function get_dial_string( $agi, $extnum, $use_confirmation, $ringgroup_index ) {
$dialstring = ‘’;

    if (strpos($extnum,'#') != 0) {
            // "#" used to identify external numbers in forwards and callgourps
            // If using call confirmation, need to put the # back into the new dialstring
            // we then place all external calls (denoted with a # at the end) through
            // the [grps] extension for the RINGGROUP_INDEX that was called. This
            // triggers the call confirmation macro along with the required messages
            // that were set.
            $extnum = str_replace("#", "", $extnum);
            if (trim($use_confirmation) == "FALSE") {
                    $dialstring = 'Local/'.$extnum.'@from-internal/n';
            } else {
                    $dialstring = 'Local/RG-'.$ringgroup_index.'-'.$extnum.'#@from-internal';
            debug("Built External dialstring component for $extnum: $dialstring", 4);
    } else {
            $device_str = sprintf("%s/device", $extnum);
            $device = $agi->database_get('AMPUSER',$device_str);
            $device = $device['data'];

            // a user can be logged into multipe devices, append the dial string for each
            $device_array = split( '&', $device );
            foreach ($device_array as $adevice) {
                    if (trim($use_confirmation) == "FALSE") {
                            $dds = $agi->database_get('DEVICE',$adevice.'/dial');
                            $dialstring .= $dds['data'];
                            $dialstring .= '&';
                    } else {
                            $dialstring .= 'Local/LC-'.$adevice.'@from-internal&';
            debug("Built External dialstring component for $extnum: $dialstring", 4);
            $dialstring = trim($dialstring," &");
    return $dialstring;


This builds the dialstring but this looks like it is done after the extension map has been built and so any additional extensions do not get checked for extension status. We don’t use voicemail or any other features so perhaps I could modify this code here in my case and just drop any state 1 extensions from the dial string.

Is this an Asterisk bug?