Example #1
0
     } else {
         if ($_REQUEST['action'] == "transfer") {
             $exten = preg_replace('/\\D/', '', $_POST["extension"]);
             // removes anything that isn't a digit.
             if (empty($exten)) {
                 echo "ERROR: Invalid extension";
             }
             $callRecord = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $_POST["call_record"]);
             $query = "Select remote_channel from asterisk_log where call_record_id='{$callRecord}'";
             $resultSet = $current_user->db->query($query, false);
             if ($current_user->db->checkError()) {
                 trigger_error("Find Remote Channel-Query failed: {$query}");
             }
             while ($row = $current_user->db->fetchByAssoc($resultSet)) {
                 $cmd = "ACTION: Redirect\r\nChannel: {$row['remote_channel']}\r\nContext: from-internal\r\nExten: {$exten}\r\nPriority: 1\r\n\r\n";
                 SendAMICommand($cmd);
             }
             // Inbound call trying, THIS WORKED!!!
             // 174-37-247-84*CLI> core show channels concise
             // SIP/207-00000f5a!from-internal!!1!Up!AppDial!(Outgoing Line)!207!!3!209!Local/207@sugarsip-ca35;2!1333295931.5214
             // Local/207@sugarsip-ca35;2!sugarsip!207!3!Up!Dial!SIP/207,,t!+14102152497!!3!214!SIP/207-00000f5a!1333295927.5213
             // Local/207@sugarsip-ca35;1!sugarsip!!1!Up!AppDial!(Outgoing Line)!207!!3!214!SIP/Flowroute-00000f59!1333295927.5212
             // SIP/Flowroute-00000f59!macro-dial!s!7!Up!Dial!Local/207@sugarsip/n,"",tr!+14102152497!!3!223!Local/207@sugarsip-ca35;1!1333295918.5211
             //$cmd ="ACTION: Redirect\r\nChannel: SIP/Flowroute-00000f59\r\nContext: from-internal\r\nExten: 208\r\nPriority: 1\r\n\r\n";
             //SendAMICommand($cmd);
             // At this point we should also update the channel in database
         } else {
             echo "Undefined Action";
         }
     }
 }
Example #2
0
function transferCall($extension, $call_record)
{
    $exten = preg_replace('/\\D/', '', $extension);
    // removes anything that isn't a digit.
    if (empty($exten)) {
        echo "ERROR: Invalid extension";
    }
    $callRecord = preg_replace('/[^a-z0-9\\-\\. ]/i', '', $call_record);
    $query = "Select remote_channel from asterisk_log where call_record_id='{$callRecord}'";
    $resultSet = $GLOBALS['current_user']->db->query($query, false);
    if ($GLOBALS['current_user']->db->checkError()) {
        trigger_error("Find Remote Channel-Query failed: {$query}");
    }
    while ($row = $GLOBALS['current_user']->db->fetchByAssoc($resultSet)) {
        $context = $GLOBALS['sugar_config']['asterisk_context'];
        $cmd = "ACTION: Redirect\r\nChannel: {$row['remote_channel']}\r\nContext: {$context}\r\nExten: {$exten}\r\nPriority: 1\r\n\r\n";
        SendAMICommand($cmd);
    }
    // Inbound call trying, THIS WORKED!!!
    // 174-37-247-84*CLI> core show channels concise
    // SIP/207-00000f5a!from-internal!!1!Up!AppDial!(Outgoing Line)!207!!3!209!Local/207@sugarsip-ca35;2!1333295931.5214
    // Local/207@sugarsip-ca35;2!sugarsip!207!3!Up!Dial!SIP/207,,t!+14102152497!!3!214!SIP/207-00000f5a!1333295927.5213
    // Local/207@sugarsip-ca35;1!sugarsip!!1!Up!AppDial!(Outgoing Line)!207!!3!214!SIP/Flowroute-00000f59!1333295927.5212
    // SIP/Flowroute-00000f59!macro-dial!s!7!Up!Dial!Local/207@sugarsip/n,"",tr!+14102152497!!3!223!Local/207@sugarsip-ca35;1!1333295918.5211
    //$cmd ="ACTION: Redirect\r\nChannel: SIP/Flowroute-00000f59\r\nContext: from-internal\r\nExten: 208\r\nPriority: 1\r\n\r\n";
    //SendAMICommand($cmd);
    // At this point we should also update the channel in database
}