コード例 #1
0
ファイル: functions.inc.php プロジェクト: lidl/announcement
function announcement_get_config($engine)
{
    global $ext;
    switch ($engine) {
        case 'asterisk':
            foreach (announcement_list() as $row) {
                $recording = recordings_get_file($row['recording_id']);
                if (!$row['noanswer']) {
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_gotoif('$["${CDR(disposition)}" = "ANSWERED"]', 'begin'));
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_answer(''));
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_wait('1'));
                } else {
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_progress());
                }
                $ext->add('app-announcement-' . $row['announcement_id'], 's', 'begin', new ext_noop('Playing announcement ' . $row['description']));
                if ($row['allow_skip'] || $row['repeat_msg']) {
                    // allow skip
                    if ($row['repeat_msg']) {
                        $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_responsetimeout(1));
                    }
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', 'play', new ext_background($recording . ',nm'));
                    if ($row['repeat_msg']) {
                        $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_waitexten(''));
                    }
                    if ($row['allow_skip']) {
                        $skip = "_[0-9*#]";
                        $ext->add('app-announcement-' . $row['announcement_id'], $skip, '', new ext_noop('User skipped announcement'));
                        if ($row['return_ivr']) {
                            $ext->add('app-announcement-' . $row['announcement_id'], $skip, '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row['post_dest'] . ':${IVR_CONTEXT},return,1'));
                        } else {
                            $ext->add('app-announcement-' . $row['announcement_id'], $skip, '', new ext_goto($row['post_dest']));
                        }
                    }
                    if ($row['repeat_msg']) {
                        $ext->add('app-announcement-' . $row['announcement_id'], $row['repeat_msg'], '', new ext_goto('s,play'));
                    }
                } else {
                    $ext->add('app-announcement-' . $row['announcement_id'], 's', '', new ext_playback($recording . ',noanswer'));
                }
                // if repeat_msg enabled then set exten to t to allow for the key to be pressed, otherwise play message and go
                $exten = $row['repeat_msg'] ? 't' : 's';
                if ($row['return_ivr']) {
                    $ext->add('app-announcement-' . $row['announcement_id'], $exten, '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row['post_dest'] . ':${IVR_CONTEXT},return,1'));
                    if ($row['allow_skip'] || $row['repeat_msg']) {
                        $ext->add('app-announcement-' . $row['announcement_id'], 'i', '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row['post_dest'] . ':${IVR_CONTEXT},return,1'));
                    }
                } else {
                    $ext->add('app-announcement-' . $row['announcement_id'], $exten, '', new ext_goto($row['post_dest']));
                    if ($row['allow_skip'] || $row['repeat_msg']) {
                        $ext->add('app-announcement-' . $row['announcement_id'], 'i', '', new ext_goto($row['post_dest']));
                    }
                }
            }
            break;
    }
}
コード例 #2
0
ファイル: functions.inc.php プロジェクト: lidl/fax
function fax_get_config($engine)
{
    global $version;
    global $ext;
    global $amp_conf;
    global $core_conf;
    $ast_ge_11 = version_compare($version, '11', 'ge');
    $ast_ge_10 = version_compare($version, '10', 'ge');
    $ast_lt_18 = version_compare($version, '1.8', 'lt');
    $ast_ge_16 = version_compare($version, '1.6', 'ge');
    $fax = fax_detect($version);
    if ($fax['module'] && ($ast_lt_18 || $fax['ffa'] || $fax['spandsp'])) {
        //dont continue unless we have a fax module in asterisk
        $t38_fb = $ast_ge_16 ? ',f' : '';
        $context = 'ext-fax';
        $dests = fax_get_destinations();
        if ($dests) {
            foreach ($dests as $row) {
                $exten = $row['user'];
                $ext->add($context, $exten, '', new ext_set('FAX_FOR', $row['name'] . ' (' . $row['user'] . ')'));
                $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_FOR}, From: ${CALLERID(all)}'));
                $ext->add($context, $exten, '', new ext_set('FAX_ATTACH_FORMAT', $row['faxattachformat']));
                $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', $row['faxemail']));
                $ext->add($context, $exten, 'receivefax', new ext_goto('receivefax', 's'));
            }
        }
        /*
          FAX Failures are not handled well as of this coding in by ReceiveFAX. If there is a license available then it provides
          information. If not, nothing is provided. FAXSTATUS is supported in 1.4 to handle legacy with RxFax(). In order to create
          dialplan to try and handle all cases, we use FAXSTATUS and set it ourselves as needed. It appears that if a fax fails with
          ReceiveFAX we can always continue execution and if it succeeds, then execution goes to hangup. So using that information
          we try to trap and report on all cases.
        */
        $exten = 's';
        $ext->add($context, $exten, '', new ext_macro('user-callerid'));
        // $cmd,n,Macro(user-callerid)
        $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'));
        $ext->add($context, $exten, 'receivefax', new ext_stopplaytones(''));
        switch ($fax['module']) {
            case 'app_rxfax':
                $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                //receive fax, then email it on
                break;
            case 'app_fax':
                // $fax['receivefax'] should be rxfax or receivefax, it could be none in which case we don't know. We'll just make it
                // ReceiveFAX in that case since it will fail anyhow.
                if ($fax['receivefax'] == 'rxfax') {
                    $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                    //receive fax, then email it on
                } elseif ($fax['receivefax'] == 'receivefax') {
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //receive fax, then email it on
                } else {
                    $ext->add($context, $exten, '', new ext_noop('ERROR: NO Receive FAX application detected, putting in dialplan for ReceiveFAX as default'));
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //receive fax, then email it on
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS}" = ""]', 'Set', 'FAXSTATUS=${IF($["${FAXOPT(error)}" = ""]?"FAILED LICENSE EXCEEDED":"FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}")}'));
                }
                break;
            case 'res_fax':
                $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                //receive fax, then email it on
                if ($ast_ge_16) {
                    if ($fax['ffa']) {
                        $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS}"="" | "${FAXSTATUS}" = "FAILED" & "${FAXERROR}" = "INIT_ERROR"]', 'Set', 'FAXSTATUS=FAILED LICENSE MAY BE EXCEEDED check log errors'));
                    }
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS:0:6}"="FAILED" && "${FAXERROR}"!="INIT_ERROR"]', 'Set', 'FAXSTATUS="FAILED: error: ${FAXERROR} statusstr: ${FAXOPT(statusstr)}"'));
                } else {
                    // Some versions or settings appear to have successful completions continue, so check status and goto hangup code
                    if ($fax['ffa']) {
                        $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"=""]', 'Set', 'FAXSTATUS=FAILED LICENSE MAY BE EXCEEDED'));
                    }
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"!="" && "${FAXOPT(error)}"!="NO_ERROR"]', 'Set', 'FAXSTATUS="FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}"'));
                }
                $ext->add($context, $exten, '', new ext_hangup());
                break;
            default:
                // unknown
                $ext->add($context, $exten, '', new ext_noop('No Known FAX Technology installed to receive a fax, aborting'));
                $ext->add($context, $exten, '', new ext_set('FAXSTATUS', 'FAILED No Known Fax Reception Apps available to process'));
                $ext->add($context, $exten, '', new ext_hangup());
        }
        $exten = 'h';
        // if there is a file there, mail it even if we failed:
        $ext->add($context, $exten, '', new ext_gotoif('$[${STAT(e,${ASTSPOOLDIR}/fax/${UNIQUEID}.tif)} = 0]', 'failed'));
        $ext->add($context, $exten, '', new ext_noop_trace('PROCESSING FAX with status: [${FAXSTATUS}] for: [${FAX_RX_EMAIL}], From: [${CALLERID(all)}]'));
        $ext->add($context, $exten, 'process', new ext_gotoif('$[${LEN(${FAX_RX_EMAIL})} = 0]', 'noemail'));
        //delete is a variable so that other modules can prevent it should then need to prosses the file further
        $ext->add($context, $exten, 'delete_opt', new ext_set('DELETE_AFTER_SEND', 'true'));
        //strreplace wasn't put into asterisk until 10, so fallback to replace to older asterisk versions
        if ($ast_ge_10) {
            $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --remotestationid "${FAXOPT(remotestationid)}" --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid \'${STRREPLACE(CALLERID(all),\',\\\\\')}\' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}" --delete "${DELETE_AFTER_SEND}" --attachformat "${FAX_ATTACH_FORMAT}"'));
        } else {
            $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax2mail.php --remotestationid "${FAXOPT(remotestationid)}" --to "${FAX_RX_EMAIL}" --dest "${FROM_DID}" --callerid \'${REPLACE(CALLERID(all),\', )}\' --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif --exten "${FAX_FOR}" --delete "${DELETE_AFTER_SEND}" --attachformat "${FAX_ATTACH_FORMAT}"'));
        }
        $ext->add($context, $exten, 'end', new ext_macro('hangupcall'));
        $ext->add($context, $exten, 'noemail', new ext_noop('ERROR: No Email Address to send FAX: status: [${FAXSTATUS}],  From: [${CALLERID(all)}]'));
        $ext->add($context, $exten, '', new ext_macro('hangupcall'));
        $ext->add($context, $exten, 'failed', new ext_noop('FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'), 'process', 101);
        $ext->add($context, $exten, '', new ext_macro('hangupcall'));
        $modulename = 'fax';
        $fcc = new featurecode($modulename, 'simu_fax');
        $fc_simu_fax = $fcc->getCodeActive();
        unset($fcc);
        if ($fc_simu_fax != '') {
            $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'FAX_RX_EMAIL\'', 'getRow');
            $ext->addInclude('from-internal-additional', 'app-fax');
            // Add the include from from-internal
            $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0]));
            $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax'));
            $ext->add('app-fax', 'h', '', new ext_macro('hangupcall'));
        }
        // This is not really needed but is put here in case some ever accidently switches the order below when
        // checking for this setting since $fax['module'] will be set there and the 2nd part never checked
        $fax_settings['force_detection'] = 'yes';
    } else {
        $fax_settings = fax_get_settings();
    }
    if ($fax['module'] && ($ast_lt_18 || $fax['ffa'] || $fax['spandsp']) || $fax_settings['force_detection'] == 'yes') {
        if ($ast_ge_11 && isset($core_conf) && is_a($core_conf, "core_conf")) {
            $core_conf->addSipGeneral('faxdetect', 'no');
        } else {
            if ($ast_ge_16 && isset($core_conf) && is_a($core_conf, "core_conf")) {
                $core_conf->addSipGeneral('faxdetect', 'yes');
            }
        }
        $ext->add('ext-did-0001', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        $ext->add('ext-did-0002', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired
        if (function_exists('ivr_list')) {
            $ivrlist = ivr_list();
            if (is_array($ivrlist)) {
                foreach ($ivrlist as $item) {
                    $ext->add("ivr-" . $item['ivr_id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
                }
            }
        }
        if (function_exists('announcement_list')) {
            foreach (announcement_list() as $row) {
                $ext->add('app-announcement-' . $row['announcement_id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
            }
        }
    }
}
コード例 #3
0
ファイル: page.announcement.php プロジェクト: hardikk/HNH
    case 'delete':
        announcement_delete($announcement_id);
        needreload();
        redirect_standard();
        break;
}
?>
 
</div>

<div class="rnav"><ul>
<?php 
// Eventually I recon the drawListMenu could be built into the new component class thus making
// the relevent page.php file unnessassary
echo '<li><a href="config.php?display=announcement&amp;type=setup">' . _('Add Announcement') . '</a></li>';
foreach (announcement_list() as $row) {
    echo '<li><a href="config.php?display=announcement&amp;type=setup&amp;extdisplay=' . $row[0] . '" class="">' . $row[1] . '</a></li>';
}
?>
</ul></div>

<div class="content">

<?php 
if ($extdisplay) {
    // load
    $row = announcement_get($extdisplay);
    $description = $row['description'];
    $recording_id = $row['recording_id'];
    $allow_skip = $row['allow_skip'];
    $post_dest = $row['post_dest'];
コード例 #4
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function fax_get_config($engine)
{
    global $version;
    global $ext;
    global $amp_conf;
    global $core_conf;
    $fax = fax_detect($version);
    if ($fax['module']) {
        //dont continue unless we have a fax module in asterisk
        $t38_fb = version_compare($version, '1.6', 'ge') ? ',f' : '';
        $context = 'ext-fax';
        $dests = fax_get_destinations();
        $sender_address = sql('SELECT value FROM fax_details WHERE `key` = \'sender_address\'', 'getRow');
        if ($dests) {
            foreach ($dests as $row) {
                $exten = $row['user'];
                $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ' . $row['name'] . ' (' . $row['user'] . '), From: ${CALLERID(all)}'));
                $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', $row['faxemail']));
                $ext->add($context, $exten, 'receivefax', new ext_goto('receivefax', 's'));
            }
        }
        /*
          FAX Failures are not handled well as of this coding in by ReceiveFAX. If there is a license available then it provides
          information. If not, nothing is provided. FAXSTATUS is supported in 1.4 to handle legacy with RxFax(). In order to create
          dialplan to try and handle all cases, we use FAXSTATUS and set it ourselves as needed. It appears that if a fax fails with
          ReceiveFAX we can always continue execution and if it succeeds, then execution goes to hangup. So using that information
          we try to trap and report on all cases.
        */
        $exten = 's';
        $ext->add($context, $exten, '', new ext_macro('user-callerid'));
        // $cmd,n,Macro(user-callerid)
        $ext->add($context, $exten, '', new ext_noop('Receiving Fax for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'));
        $ext->add($context, $exten, 'receivefax', new ext_stopplaytones(''));
        switch ($fax['module']) {
            case 'app_rxfax':
                $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                //recive fax, then email it on
                break;
            case 'app_fax':
                // $fax['receivefax'] should be rxfax or receivefax, it could be none in which case we don't know. We'll just make it
                // ReceiveFAX in that case since it will fail anyhow.
                if ($fax['receivefax'] == 'rxfax') {
                    $ext->add($context, $exten, '', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
                    //recive fax, then email it on
                } elseif ($fax['receivefax'] == 'receivefax') {
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //recive fax, then email it on
                } else {
                    $ext->add($context, $exten, '', new ext_noop('ERROR: NO Receive FAX application detected, putting in dialplan for ReceiveFAX as default'));
                    $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                    //recive fax, then email it on
                    $ext->add($context, $exten, '', new ext_execif('$["${FAXSTATUS}" = ""]', 'Set', 'FAXSTATUS=${IF($["${FAXOPT(error)}" = ""]?"FAILED LICENSE EXCEEDED":"FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}")}'));
                }
                break;
            case 'res_fax':
                $ext->add($context, $exten, '', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif' . $t38_fb));
                //recive fax, then email it on
                // Some versions or settings appear to have successful completions continue, so check status and goto hangup code
                $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"=""]', 'Set', 'FAXSTATUS=FAILED LICENSE EXCEEDED'));
                $ext->add($context, $exten, '', new ext_execif('$["${FAXOPT(error)}"!="" && "${FAXOPT(error)}"!="NO_ERROR"]', 'Set', 'FAXSTATUS="FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}"'));
                $ext->add($context, $exten, '', new ext_hangup());
                break;
            default:
                // unknown
                $ext->add($context, $exten, '', new ext_noop('No Known FAX Technology installed to receive a fax, aborting'));
                $ext->add($context, $exten, '', new ext_set('FAXSTATUS', 'FAILED No Known Fax Reception Apps available to process'));
                $ext->add($context, $exten, '', new ext_hangup());
        }
        $exten = 'h';
        $ext->add($context, $exten, '', new ext_gotoif('$["${FAXSTATUS:0:6}" = "FAILED"]', 'failed'));
        $ext->add($context, $exten, 'process', new ext_gotoif('$[${LEN(${FAX_RX_EMAIL})} = 0]', 'end'));
        $ext->add($context, $exten, '', new ext_system('${ASTVARLIBDIR}/bin/fax-process.pl --to "${FAX_RX_EMAIL}" --from "' . $sender_address['0'] . '" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(name)})} ${URIENCODE(<${CALLERID(number)}>)}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif'));
        $ext->add($context, $exten, 'end', new ext_macro('hangupcall'));
        $ext->add($context, $exten, 'failed', new ext_noop('FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'), 'process', 101);
        $ext->add($context, $exten, '', new ext_macro('hangupcall'));
        //write out res_fax.conf and res_fax_digium.conf
        fax_write_conf();
        $modulename = 'fax';
        $fcc = new featurecode($modulename, 'simu_fax');
        $fc_simu_fax = $fcc->getCodeActive();
        unset($fcc);
        if ($fc_simu_fax != '') {
            $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'FAX_RX_EMAIL\'', 'getRow');
            $ext->addInclude('from-internal-additional', 'app-fax');
            // Add the include from from-internal
            $ext->add('app-fax', $fc_simu_fax, '', new ext_setvar('FAX_RX_EMAIL', $default_address[0]));
            $ext->add('app-fax', $fc_simu_fax, '', new ext_goto('1', 's', 'ext-fax'));
            $ext->add('app-fax', 'h', '', new ext_macro('hangupcall'));
        }
        // This is not really needed but is put here in case some ever accidently switches the order below when
        // checking for this setting since $fax['module'] will be set there and the 2nd part never checked
        $fax_settings['force_detection'] = 'yes';
    } else {
        $fax_settings = fax_get_settings();
    }
    if ($fax['module'] | $fax_settings['force_detection'] == 'yes') {
        //dont continue unless we have a fax module in asterisk
        $ast_ge_16 = version_compare($version, '1.6', 'ge');
        if ($ast_ge_16 && isset($core_conf) && is_a($core_conf, "core_conf")) {
            $core_conf->addSipGeneral('faxdetect', 'yes');
        }
        $ext->add('ext-did-0001', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        $ext->add('ext-did-0002', 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
        // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired
        if (function_exists('ivr_list')) {
            $ivrlist = ivr_list();
            if (is_array($ivrlist)) {
                foreach ($ivrlist as $item) {
                    $ext->add("ivr-" . $item['ivr_id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
                }
            }
        }
        if (function_exists('announcement_list')) {
            foreach (announcement_list() as $row) {
                $ext->add('app-announcement-' . $row['announcement_id'], 'fax', '', new ext_goto('${CUT(FAX_DEST,^,1)},${CUT(FAX_DEST,^,2)},${CUT(FAX_DEST,^,3)}'));
            }
        }
    }
}