示例#1
0
function get_agent_status($queue, $agent)
{
    global $queue_members;
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'Aastra_asm_event_queues_Asterisk');
    $asm->add_event_handler('queuemember', 'Aastra_asm_event_agents_Asterisk');
    # Retrieve info
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Get info for the given queue
    $status['Logged'] = False;
    $status['Paused'] = False;
    foreach ($queue_members as $agent_a) {
        if ($agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
            $status['Logged'] = True;
            if ($agent_a['Paused'] == '1') {
                $status['Paused'] = True;
            }
            $status['Type'] = $agent_a['Membership'];
            $status['CallsTaken'] = $agent_a['CallsTaken'];
            $status['LastCall'] = $agent_a['LastCall'];
            break;
        }
        # Get Penalty
        $penalty = $asm->database_get('QPENALTY', $queue . '/agents/' . $agent);
        if ($penalty == '') {
            $penalty = '0';
        }
        $status['Penalty'] = $penalty;
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $status;
}
function Aastra_get_bulk_callerid_Asterisk($array)
{
    global $ASTERISK_LOCATION;
    global $AA_FREEPBX_MODE;
    global $language;
    # Try in the config file first
    $sip_array = Aastra_readINIfile($ASTERISK_LOCATION . 'sip_additional.conf', ';', '=');
    # Connect to AGI
    $as = new AGI_AsteriskManager();
    $res = $as->connect();
    # Process all the extensions
    foreach ($array as $key => $value) {
        # No name by default
        $name = '';
        # Extension exists?
        if ($sip_array[$value['number']] == NULL) {
            if ($AA_FREEPBX_MODE == '1') {
                $name = Aastra_get_label('Unknown', $language);
            }
        } else {
            # FreePBX old school
            if (!strstr($sip_array[$value['number']]['callerid'], 'device')) {
                # Retrieve the value
                $temp = explode(" <", $sip_array[$value['number']]['callerid'], 2);
                $number = $temp[0];
            }
        }
        # Still not found
        if ($name == '') {
            # Get value in the database
            $name = $as->database_get('AMPUSER', $value['number'] . '/cidname');
        }
        # Complete caller ID
        $array[$key]['name'] = $name;
    }
    # Disconnect properly
    $as->disconnect();
    # Return Caller ID
    return $array;
}
示例#3
0
function setrobstatus($account, $incomingvalue, $mode)
{
    require_once 'common/php-asmanager.php';
    $amp_conf = parse_amportal_conf("/etc/amportal.conf");
    $hosts = split(',', $amp_conf['MANAGERHOSTS']);
    foreach ($hosts as $host) {
        $astman = new AGI_AsteriskManager();
        if ($res = $astman->connect($host, $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"])) {
            if ($mode == "write") {
                if ($incomingvalue == "Never") {
                    $astman->database_del("ROBCHECK", $account);
                }
                if ($incomingvalue == "Always") {
                    $astman->database_put("ROBCHECK", $account, "ENABLED");
                }
                $robstatus = null;
            }
            if ($mode == "read") {
                $existrobstatus = $astman->database_get("ROBCHECK", $account);
                if ($existrobstatus) {
                    $robstatus = "Always";
                } else {
                    $robstatus = "Never";
                }
            }
            $astman->disconnect();
        } else {
            echo "<h3>Cannot connect to Asterisk Manager {$host} with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"] . "</h3>This module requires access to the Asterisk Manager.  Please ensure Asterisk is running and access to the manager is available.</div>";
            exit;
        }
    }
    return $robstatus;
}
示例#4
0
function get_agent_status($queue, $agent)
{
    global $queue_members;
    $queue_members = '';
    # Transcode for device and user mode
    $agent = Aastra_get_userdevice_Asterisk($agent);
    # Connect to AGI
    $asm = new AGI_AsteriskManager();
    $asm->connect();
    # Add event handlers to retrieve the answer
    $asm->add_event_handler('queuestatuscomplete', 'asm_event_queues');
    $asm->add_event_handler('queuemember', 'asm_event_agents');
    # Retrieve info
    $count = 0;
    while (!$queue_members) {
        $asm->QueueStatus();
        $count++;
        if ($count == 10) {
            break;
        }
    }
    # Process info
    if ($queue != '') {
        # Get info for the given queue
        $status['Logged'] = False;
        $status['Paused'] = False;
        foreach ($queue_members as $agent_a) {
            if ($agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Queue'] == $queue && $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
                $status['Logged'] = True;
                if ($agent_a['Paused'] == '1') {
                    $status['Paused'] = True;
                }
                $status['CallsTaken'] = $agent_a['CallsTaken'];
                $status['LastCall'] = $agent_a['LastCall'];
                break;
            }
        }
        # Get agent type
        $db = Aastra_connect_freePBX_db_Asterisk();
        $sql = "SELECT id FROM queues_details WHERE data LIKE 'Local/" . $agent . "@%' AND id=" . $queue;
        $result = $db->query($sql);
        if (sizeof($result->fetchRow(DB_FETCHMODE_ARRAY)) > 0) {
            $status['Type'] = 'static';
        } else {
            $status['Type'] = 'dynamic';
        }
        # Get Penalty
        $penalty = $asm->database_get('QPENALTY', $queue . '/agents/' . $agent);
        if ($penalty == '') {
            $penalty = '0';
        }
        $status['Penalty'] = $penalty;
    } else {
        # Get info for all the queues for the agent
        foreach ($queue_members as $agent_a) {
            # Dynamic agents are using from-queue context, static agents are using from-internal
            if ($agent_a['Location'] == 'Local/' . $agent . '@from-queue/n' or $agent_a['Location'] == 'Local/' . $agent . '@from-internal/n') {
                $status[$agent_a['Queue']]['Status'] = 1;
                if ($agent_a['Paused'] == '1') {
                    $status[$agent_a['Queue']]['Status'] = 2;
                }
                $status[$agent_a['Queue']]['Membership'] = $agent_a['Membership'];
            }
        }
    }
    # Disconnect properly
    $asm->disconnect();
    # Return Status
    return $status;
}