Exemplo n.º 1
0
<?php

if (!defined('FREEPBX_IS_AUTH')) {
    die('No direct script access allowed');
}
//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2015 Sangoma Technologies.
//
$fmlist = findmefollow_list();
$fmlist = is_array($fmlist) ? $fmlist : array();
$fmrows = '';
foreach ($fmlist as $fm) {
    $thisg = findmefollow_get($fm, 1);
    $fmrows .= '<tr>';
    $fmrows .= '<td><a href="?display=findmefollow&view=form&extdisplay=GRP-' . urlencode($fm) . '"><i class="fa fa-edit"></i>&nbsp;' . $fm . '</a></td>';
    $fmrows .= '<td>';
    $fmrows .= '<span class="radioset">';
    $fmrows .= '<input type="radio" name="fmtoggle' . $fm . '" id="fmtoggle' . $fm . 'yes" data-for="' . $fm . '" ' . ($thisg['ddial'] == 'CHECKED' ? '' : 'CHECKED') . '>';
    $fmrows .= '<label for="fmtoggle' . $fm . 'yes">' . _("Yes") . '</label>';
    $fmrows .= '<input type="radio" name="fmtoggle' . $fm . '" id="fmtoggle' . $fm . 'no" data-for="' . $fm . '" ' . ($thisg['ddial'] == 'CHECKED' ? 'CHECKED' : '') . ' value="CHECKED">';
    $fmrows .= '<label for="fmtoggle' . $fm . 'no">' . _("No") . '</label>';
    $fmrows .= '</span>';
}
?>

<table data-show-columns="true" data-toggle="table" data-pagination="true" data-search="true" class="table table-striped">
<thead>
	<tr>
		<th data-sortable="true"><?php 
echo _("Followme Extension");
?>
Exemplo n.º 2
0
function findmefollow_get_config($engine)
{
    global $ext;
    // is this the best way to pass this?
    global $amp_conf;
    switch ($engine) {
        case "asterisk":
            if ($amp_conf['USEDEVSTATE']) {
                $ext->addGlobal('FMDEVSTATE', 'TRUE');
            }
            $fcc = new featurecode('findmefollow', 'fmf_toggle');
            $fmf_code = $fcc->getCodeActive();
            unset($fcc);
            if ($fmf_code != '') {
                findmefollow_fmf_toggle($fmf_code);
            }
            $ext->addInclude('from-internal-additional', 'ext-findmefollow');
            $ext->addInclude('from-internal-additional', 'fmgrps');
            $contextname = 'ext-findmefollow';
            // Before creating all the contexts, let's make a list of hints if needed
            //
            if ($amp_conf['USEDEVSTATE'] && $fmf_code != '') {
                $device_list = core_devices_list("all", 'full', true);
                foreach ($device_list as $device) {
                    if ($device['tech'] == 'sip' || $device['tech'] == 'iax2') {
                        $ext->add($contextname, $fmf_code . $device['id'], '', new ext_goto("1", $fmf_code, "app-fmf-toggle"));
                        $ext->addHint($contextname, $fmf_code . $device['id'], "Custom:FOLLOWME" . $device['id']);
                    }
                }
            }
            $ringlist = findmefollow_full_list();
            if (is_array($ringlist)) {
                foreach ($ringlist as $item) {
                    $grpnum = ltrim($item['0']);
                    $grp = findmefollow_get($grpnum);
                    $strategy = $grp['strategy'];
                    $grptime = $grp['grptime'];
                    $grplist = $grp['grplist'];
                    $postdest = $grp['postdest'];
                    $grppre = isset($grp['grppre']) ? $grp['grppre'] : '';
                    $annmsg_id = $grp['annmsg_id'];
                    $dring = $grp['dring'];
                    $needsconf = $grp['needsconf'];
                    $remotealert_id = $grp['remotealert_id'];
                    $toolate_id = $grp['toolate_id'];
                    $ringing = $grp['ringing'];
                    $pre_ring = $grp['pre_ring'];
                    if ($ringing == 'Ring' || empty($ringing)) {
                        $dialopts = '${DIAL_OPTIONS}';
                    } else {
                        // We need the DIAL_OPTIONS variable
                        $sops = sql("SELECT value from globals where variable='DIAL_OPTIONS'", "getRow");
                        $dialopts = "m({$ringing})" . str_replace('r', '', $sops[0]);
                    }
                    // Direct target to Follow-Me come here bypassing the followme/ddial conditional check
                    //
                    $ext->add($contextname, 'FM' . $grpnum, '', new ext_goto("FM{$grpnum}", "{$grpnum}"));
                    //
                    // If the followme is configured for extension dialing to go to the the extension and not followme then
                    // go there. This is often used in VmX Locater functionality when the user does not want the followme
                    // to automatically be called but only if chosen by the caller as an alternative to going to voicemail
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$[ "${DB(AMPUSER/' . $grpnum . '/followme/ddial)}" = "EXTENSION" ]', 'ext-local,' . $grpnum . ',1'));
                    $ext->add($contextname, $grpnum, 'FM' . $grpnum, new ext_macro('user-callerid'));
                    $ext->add($contextname, $grpnum, '', new ext_set('__EXTTOCALL', '${EXTEN}'));
                    // block voicemail until phone is answered at which point a macro should be called on the answering
                    // line to clear this flag so that subsequent transfers can occur, if already set by a the caller
                    // then don't change.
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${BLKVM_OVERRIDE}" = "foo"]', 'skipdb'));
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]', 'skipov'));
                    $ext->add($contextname, $grpnum, 'skipdb', new ext_setvar('__NODEST', ''));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_OVERRIDE', 'BLKVM/${EXTEN}/${CHANNEL}'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_BASE', '${EXTEN}'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('DB(${BLKVM_OVERRIDE})', 'TRUE'));
                    // Remember if NODEST was set later, but clear it in case the call is answered so that subsequent
                    // transfers work.
                    //
                    $ext->add($contextname, $grpnum, 'skipov', new ext_setvar('RRNODEST', '${NODEST}'));
                    $ext->add($contextname, $grpnum, 'skipvmblk', new ext_setvar('__NODEST', '${EXTEN}'));
                    $ext->add($contextname, $grpnum, '', new ext_gosubif('$[${DB_EXISTS(AMPUSER/' . $grpnum . '/followme/changecid)} = 1 & "${DB(AMPUSER/' . $grpnum . '/followme/changecid)}" != "default" & "${DB(AMPUSER/' . $grpnum . '/followme/changecid)}" != ""]', 'sub-fmsetcid,s,1'));
                    // deal with group CID prefix
                    // but strip only if you plan on setting a new one
                    if ($grppre != '') {
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RGPREFIX}" = "foo"]', 'REPCID'));
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["${RGPREFIX}" != "${CALLERID(name):0:${LEN(${RGPREFIX})}}"]', 'REPCID'));
                        $ext->add($contextname, $grpnum, '', new ext_noop('Current RGPREFIX is ${RGPREFIX}....stripping from Caller ID'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)', '${CALLERID(name):${LEN(${RGPREFIX})}}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', ''));
                        $ext->add($contextname, $grpnum, 'REPCID', new ext_noop('CALLERID(name) is ${CALLERID(name)}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', $grppre));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)', '${RGPREFIX}${CALLERID(name)}'));
                    }
                    // recording stuff
                    $ext->add($contextname, $grpnum, '', new ext_setvar('RecordMethod', 'Group'));
                    // append the followme's extension to the grouplist. This may be redundant but will ensure recording if the extension itself is not part of
                    // the list
                    $ext->add($contextname, $grpnum, '', new ext_macro('record-enable', '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}-{$grpnum}" . ',${RecordMethod}'));
                    // MODIFIED (PL)
                    // Add Alert Info if set but don't override and already set value (could be from ringgroup, directdid, etc.)
                    //
                    if ((isset($dring) ? $dring : '') != '') {
                        // If ALERTINFO is set, then skip to the next set command. This was modified to two lines because the previous
                        // IF() couldn't handle ':' as part of the string. The jump to PRIORITY+2 allows for now destination label
                        // which is needed in the 2.3 version.
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["x${ALERT_INFO}"!="x"]', '$[${PRIORITY}+2])}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar("__ALERT_INFO", str_replace(';', '\\;', $dring)));
                    }
                    // If pre_ring is set, then ring this number of seconds prior to moving on
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$[$[ "${DB(AMPUSER/' . $grpnum . '/followme/prering)}" = "0" ] | $[ "${DB(AMPUSER/' . $grpnum . '/followme/prering)}" = "" ]] ', 'skipsimple'));
                        $ext->add($contextname, $grpnum, '', new ext_macro('simple-dial', $grpnum . ',${DB(AMPUSER/' . "{$grpnum}/followme/prering)}"));
                    }
                    // group dial
                    $ext->add($contextname, $grpnum, 'skipsimple', new ext_setvar('RingGroupMethod', $strategy));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('_FMGRP', $grpnum));
                    if (isset($annmsg_id) ? $annmsg_id : '') {
                        $annmsg = recordings_get_file($annmsg_id);
                        // should always answer before playing anything, shouldn't we ?
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$[$["${DIALSTATUS}" = "ANSWER"] | $["foo${RRNODEST}" != "foo"]]', 'DIALGRP'));
                        $ext->add($contextname, $grpnum, '', new ext_answer(''));
                        $ext->add($contextname, $grpnum, '', new ext_wait(1));
                        $ext->add($contextname, $grpnum, '', new ext_playback($annmsg));
                    }
                    // Create the confirm target
                    $len = strlen($grpnum) + 4;
                    $remotealert = recordings_get_file($remotealert_id);
                    $toolate = recordings_get_file($toolate_id);
                    $ext->add("fmgrps", "_RG-{$grpnum}-.", '', new ext_macro('dial', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)}," . "M(confirm^{$remotealert}^{$toolate}^{$grpnum}){$dialopts}" . ',${EXTEN:' . $len . '}'));
                    // If grpconf == ENABLED call with confirmation ELSE call normal
                    $ext->add($contextname, $grpnum, 'DIALGRP', new ext_gotoif('$[ "${DB(AMPUSER/' . $grpnum . '/followme/grpconf)}" = "ENABLED" ]', 'doconfirm'));
                    // Normal call
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, '', new ext_macro('dial', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)},{$dialopts}," . '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}"));
                    } else {
                        $ext->add($contextname, $grpnum, '', new ext_macro('dial', '$[ ${DB(AMPUSER/' . $grpnum . '/followme/grptime)} + ${DB(AMPUSER/' . $grpnum . '/followme/prering)} ],' . $dialopts . ',${DB(AMPUSER/' . $grpnum . '/followme/grplist)}'));
                    }
                    $ext->add($contextname, $grpnum, '', new ext_goto('nextstep'));
                    // Call Confirm call
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)},{$dialopts}," . '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}," . $grpnum));
                    } else {
                        $ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm', '$[ ${DB(AMPUSER/' . $grpnum . '/followme/grptime)} + ${DB(AMPUSER/' . $grpnum . '/followme/prering)} ],' . $dialopts . ',${DB(AMPUSER/' . $grpnum . '/followme/grplist)},' . $grpnum));
                    }
                    $ext->add($contextname, $grpnum, 'nextstep', new ext_setvar('RingGroupMethod', ''));
                    // Did the call come from a queue or ringgroup, if so, don't go to the destination, just end and let
                    // the queue or ringgroup decide what to do next
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RRNODEST}" != "foo"]', 'nodest'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__NODEST', ''));
                    $ext->add($contextname, $grpnum, '', new ext_dbdel('${BLKVM_OVERRIDE}'));
                    // where next?
                    if ((isset($postdest) ? $postdest : '') != '') {
                        $ext->add($contextname, $grpnum, '', new ext_goto($postdest));
                    } else {
                        $ext->add($contextname, $grpnum, '', new ext_hangup(''));
                    }
                    $ext->add($contextname, $grpnum, 'nodest', new ext_noop('SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST}'));
                }
                /*
                  ASTDB Settings:
                  AMPUSER/nnn/followme/changecid default | did | fixed | extern
                  AMPUSER/nnn/followme/fixedcid XXXXXXXX
                
                  changecid:
                    default   - works as always, same as if not present
                    fixed     - set to the fixedcid
                    extern    - set to the fixedcid if the call is from the outside only
                    did       - set to the DID that the call came in on or leave alone, treated as foreign
                    forcedid  - set to the DID that the call came in on or leave alone, not treated as foreign
                  
                  EXTTOCALL   - has the exten num called, hoaky if that goes away but for now use it
                */
                if (count($ringlist)) {
                    $contextname = 'sub-fmsetcid';
                    $exten = 's';
                    $ext->add($contextname, $exten, '', new ext_goto('1', 's-${DB(AMPUSER/${EXTTOCALL}/followme/changecid)}'));
                    $exten = 's-fixed';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-extern';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)})}" == "1" & "${FROM_DID}" != ""]', 'Set', '__TRUNKCIDOVERRIDE=${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-did';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__REALCALLERIDNUM=${FROM_DID}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-forcedid';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${FROM_DID}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = '_s-.';
                    $ext->add($contextname, $exten, '', new ext_noop('Unknown value for AMPUSER/${EXTTOCALL}/followme/changecid of ${DB(AMPUSER/${EXTTOCALL}/followme/changecid)} set to "default"'));
                    $ext->add($contextname, $exten, '', new ext_setvar('DB(AMPUSER/${EXTTOCALL}/followme/changecid)', 'default'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                }
            }
            break;
    }
}
Exemplo n.º 3
0
function findmefollow_getdestinfo($dest)
{
    if (substr(trim($dest), 0, 17) == 'ext-findmefollow,' || substr(trim($dest), 0, 10) == 'ext-local,' && substr(trim($dest), -4) == 'dest') {
        $grp = explode(',', $dest);
        $grp = ltrim($grp[1], 'FM');
        $thisgrp = findmefollow_get($grp);
        if (empty($thisgrp)) {
            return array();
        } else {
            return array('description' => sprintf(_("Follow Me: %s"), urlencode($grp)), 'edit_url' => 'config.php?display=findmefollow&extdisplay=GRP-' . urlencode($grp));
        }
    } else {
        return false;
    }
}
Exemplo n.º 4
0
<?php

//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2015 Sangoma Technologies.
//
extract($request);
if ($extdisplay != "") {
    // We need to populate grplist with the existing extension list.
    $extdisplay = ltrim($extdisplay, 'GRP-');
    $followme_exten = $extdisplay;
    $thisgrp = findmefollow_get($extdisplay, 1);
    $grpliststr = isset($thisgrp['grplist']) ? $thisgrp['grplist'] : '';
    $grplist = explode("-", $grpliststr);
    $strategy = isset($thisgrp['strategy']) ? $thisgrp['strategy'] : '';
    $grppre = isset($thisgrp['grppre']) ? $thisgrp['grppre'] : '';
    $grptime = isset($thisgrp['grptime']) ? $thisgrp['grptime'] : '';
    $annmsg_id = isset($thisgrp['annmsg_id']) ? $thisgrp['annmsg_id'] : '';
    $dring = isset($thisgrp['dring']) ? $thisgrp['dring'] : '';
    $remotealert_id = isset($thisgrp['remotealert_id']) ? $thisgrp['remotealert_id'] : '';
    $needsconf = isset($thisgrp['needsconf']) ? $thisgrp['needsconf'] : '';
    $toolate_id = isset($thisgrp['toolate_id']) ? $thisgrp['toolate_id'] : '';
    $ringing = isset($thisgrp['ringing']) ? $thisgrp['ringing'] : '';
    $pre_ring = isset($thisgrp['pre_ring']) ? $thisgrp['pre_ring'] : '';
    $ddial = isset($thisgrp['ddial']) ? $thisgrp['ddial'] : '';
    $changecid = isset($thisgrp['changecid']) ? $thisgrp['changecid'] : 'default';
    $fixedcid = isset($thisgrp['fixedcid']) ? $thisgrp['fixedcid'] : '';
    $goto = isset($thisgrp['postdest']) ? $thisgrp['postdest'] : (isset($thisgrp['voicemail']) && $thisgrp['voicemail'] != 'novm' ? "ext-local,vmu{$extdisplay},1" : '');
    unset($grpliststr);
    unset($thisgrp);
}
//Ring Strategy Help
Exemplo n.º 5
0
 /**
  * @verb GET
  * @returns - a list of users' find me follow me settings
  * @uri /findmefollow/users/:id
  */
 function get_findmefollow_users_id($params)
 {
     $users = findmefollow_get($params['id'], 1);
     return $users ? $users : false;
 }