Example #1
0
} else {
    include "custom/modules/Asterisk/language/en_us.lang.php";
}
//logLine("At Top\n", "c:/controller.log");
//ACTIONS
switch ($_REQUEST['action']) {
    case "memoSave":
        if ($_REQUEST['call_record']) {
            memoSave($_REQUEST['call_record'], $_REQUEST['sugar_user_id'], $_REQUEST['phone_number'], $_REQUEST['description'], $_REQUEST['direction']);
        }
        break;
    case "updateUIState":
        updateUIState($_REQUEST['ui_state'], $_REQUEST['call_record'], $_REQUEST['id']);
        break;
    case "setBeanID":
        setBeanID($_REQUEST['call_record'], $_REQUEST['bean_module'], $_REQUEST['bean_id']);
        break;
    case "call":
        callCreate();
        break;
    case "transfer":
        transferCall($_REQUEST["extension"], $_REQUEST['call_record']);
        break;
    case "block":
        blockNumber($_REQUEST['number'], $_REQUEST['description']);
        break;
    case "get_calls":
        getCalls($mod_strings, $GLOBALS['current_user']);
        break;
    default:
        echo "undefined action";
Example #2
0
/**
 * Build the item list
 *
 * @param array $result_set Array of calls from database
 * @param object $current_user SugarCRM current_user object allows DB access
 * @param array $mod_strings SugarCRM module strings
 * @return array
 */
function build_getCalls_item_list($result_set, $current_user, $mod_strings)
{
    global $sugar_config;
    $response = array();
    $index = 0;
    $numCalls = $current_user->db->getRowCount($result_set);
    $maxCalls = $sugar_config['asterisk_max_popups'];
    while ($row = $current_user->db->fetchByAssoc($result_set)) {
        // If we have too many calls, we nuke the extra from beginning of result_set since they're the oldest.
        if ($numCalls > $maxCalls && $index++ < $numCalls - $maxCalls) {
            updateUIState("Closed", $row['call_record_id'], $row['asterisk_id']);
            //logLine("Too many active popups, closing {$row['asterisk_id']}");
        } else {
            $state = get_call_state($row, $mod_strings);
            $phone_number = get_callerid($row);
            $call_direction = get_call_direction($row, $mod_strings);
            $contacts = array();
            // Dont fetch contacts if it's already known this is already been related to another module.
            if (!empty($row['bean_module']) && !empty($row['bean_id'])) {
                $beans = make_bean_array_from_call_row($row);
            } else {
                // @@@@ BEGIN CALLINIZE COMMUNITY ONLY @@@@
                $module_list = "accounts,contacts";
                // @@@@ END CALLINIZE COMMUNITY ONLY @@@@
                $beans = find_beans($phone_number, $module_list, false, $current_user);
            }
            // When only one matching number, save the result in call record.
            if (count($beans) == 1) {
                setBeanID($row['call_record_id'], $beans[0]['bean_module'], $beans[0]['bean_id']);
            }
            $call = array('id' => $row['id'], 'asterisk_id' => $row['asterisk_id'], 'state' => $state, 'is_hangup' => $state == $mod_strings['YAAI']['HANGUP'], 'call_record_id' => $row['call_record_id'], 'phone_number' => $phone_number, 'timestamp_call' => $row['timestamp_call'], 'title' => get_title($beans, $phone_number, $state, $mod_strings), 'beans' => $beans, 'call_type' => $call_direction['call_type'], 'direction' => $call_direction['direction'], 'duration' => get_duration($row), 'mod_strings' => $mod_strings['YAAI']);
            $response[] = $call;
        }
    }
    return $response;
}