Esempio n. 1
0
/** Moved to BMO hook
function fax_hook_core($viewing_itemid, $target_menuid){}
*/
function fax_hookGet_config($engine)
{
    global $version;
    $ast_ge_11 = version_compare($version, '11', 'ge');
    $fax = fax_detect($version);
    if ($fax['module']) {
        $fax_settings['force_detection'] = 'yes';
    } else {
        $fax_settings = fax_get_settings();
    }
    if ($fax_settings['force_detection'] == 'yes') {
        //dont continue unless we have a fax module in asterisk
        global $ext;
        global $engine;
        $routes = fax_get_incoming();
        foreach ($routes as $current => $route) {
            if ($route['detection'] == 'nvfax' && !$fax['nvfax']) {
                //TODO: add notificatoin to notification panel that this was skipped because NVFaxdetec not present
                continue;
                // skip this one if there is no NVFaxdetect installed on this system
            }
            if ($route['extension'] == '' && $route['cidnum']) {
                //callerID only
                $extension = 's/' . $route['cidnum'];
                $context = $route['pricid'] == 'CHECKED' ? 'ext-did-0001' : 'ext-did-0002';
            } else {
                if ($route['extension'] && $route['cidnum'] || $route['extension'] == '' && $route['cidnum'] == '') {
                    //callerid+did / any/any
                    $context = 'ext-did-0001';
                } else {
                    //did only
                    $context = 'ext-did-0002';
                }
                $extension = ($route['extension'] != '' ? $route['extension'] : 's') . ($route['cidnum'] == '' ? '' : '/' . $route['cidnum']);
            }
            if ($route['legacy_email'] === null) {
                $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_DEST', str_replace(',', '^', $route['destination'])));
            } else {
                $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_DEST', 'ext-fax^s^1'));
                if ($route['legacy_email']) {
                    $fax_rx_email = $route['legacy_email'];
                } else {
                    if (!isset($default_fax_rx_email)) {
                        $default_address = sql('SELECT value FROM fax_details WHERE `key` = \'fax_rx_email\'', 'getRow');
                        $default_fax_rx_email = $default_address[0];
                    }
                    $fax_rx_email = $default_fax_rx_email;
                }
                $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAX_RX_EMAIL', $fax_rx_email));
            }
            //If we have fax incoming, we need to set fax detection to yes if we are on Asterisk 11 or newer
            if ($ast_ge_11) {
                $ext->splice($context, $extension, 'dest-ext', new ext_setvar('FAXOPT(faxdetect)', 'yes'));
            }
            $ext->splice($context, $extension, 'dest-ext', new ext_answer(''));
            if ($route['detection'] == 'nvfax') {
                $ext->splice($context, $extension, 'dest-ext', new ext_playtones('ring'));
                $ext->splice($context, $extension, 'dest-ext', new ext_nvfaxdetect($route['detectionwait'] . ",t"));
            } else {
                $ext->splice($context, $extension, 'dest-ext', new ext_wait($route['detectionwait']));
            }
        }
    }
}
Esempio n. 2
0
    public function coreDIDHook($page)
    {
        if ($page == 'did') {
            $target_menuid = $page;
            $tabindex = null;
            $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
            $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : '';
            $cidnum = isset($_REQUEST['cidnum']) ? $_REQUEST['cidnum'] : '';
            $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : '';
            //if were editing, get save parms. Get parms
            if (!$extension && !$cidnum) {
                //set $extension,$cidnum if we dont already have them
                if ($extdisplay) {
                    $opts = explode('/', $extdisplay);
                    $extension = $opts['0'];
                    $cidnum = isset($opts['1']) ? $opts['1'] : '';
                } else {
                    $extension = $cidnum = '';
                }
            }
            $fax = fax_get_incoming($extension, $cidnum);
            $html = $fdinput = '';
            if ($target_menuid == 'did') {
                $fax_dahdi_faxdetect = fax_dahdi_faxdetect();
                $fax_sip_faxdetect = fax_sip_faxdetect();
                $dahdi = ast_with_dahdi() ? _('Dahdi') : _('Zaptel');
                $fax_detect = fax_detect();
                $fax_settings = fax_get_settings();
                //ensure that we are using destination for both fax detect and the regular calls
                $html = '<script type="text/javascript">$(document).ready(function(){
				$("input[name=Submit]").click(function(){
					if($("input[name=faxenabled]:checked").val()=="true" && !$("[name=gotoFAX]").val()){//ensure the user selected a fax destination
					alert(' . _('"You have selected Fax Detection on this route. Please select a valid destination to route calls detected as faxes to."') . ');return false; }	}) });</script>';
                $fdhelp = _("Attempt to detect faxes on this DID.");
                $fdhelp .= '<ul>';
                $fdhelp .= '<li>' . _("No: No attempts are made to auto-determine the call type; all calls sent to destination set in the 'General' tab. Use this option if this DID is used exclusively for voice OR fax.") . '</li>';
                $fdhelp .= '<li>' . _("Yes: try to auto determine the type of call; route to the fax destination if call is a fax, otherwise send to regular destination. Use this option if you receive both voice and fax calls on this line") . '</li>';
                if ($fax_settings['legacy_mode'] == 'yes' || $fax['legacy_email'] !== null) {
                    $fdhelp .= '<li>' . _('Legacy: Same as YES, only you can enter an email address as the destination. This option is ONLY for supporting migrated legacy fax routes. You should upgrade this route by choosing YES, and selecting a valid destination!') . '</li>';
                }
                $fdhelp .= '</ul>';
                //dont allow detection to be set if we have no valid detection types
                if (!$fax_dahdi_faxdetect && !$fax_sip_faxdetect && !$fax_detect['nvfax']) {
                    $js = "if (\$(this).val() == 'true'){alert('" . _('No fax detection methods found or no valid license. Faxing cannot be enabled.') . "');return false;}";
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_yes" value="true"  onclick="' . $js . '"/><label for="faxenabled_yes">Yes</label></span>';
                    $fdinput .= '<input type="radio" id="faxenabled_no" name="faxenabled" value="false" CHECKED /><label for="faxenabled_no">No</label>';
                } else {
                    /*
                     * show detection options
                     *
                     * js to show/hide the detection settings. Second slide is always in a
                     * callback so that we ait for the fits animation to complete before
                     * playing the second
                     */
                    $faxing = !empty($fax);
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_yes" value="true" ' . ($faxing ? 'CHECKED' : '') . ' /><label for="faxenabled_yes">' . _('Yes') . '</label>';
                    $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_no" value="false" ' . (!$faxing ? 'CHECKED' : '') . '/><label for="faxenabled_no">' . _('No') . '</label>';
                    if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
                        $fdinput .= '<input type="radio" name="faxenabled" id="faxenabled_legacy" value="legacy"' . ($fax['legacy_email'] !== null ? ' CHECKED ' : '') . 'onclick="' . $jslegacy . '"/><label for="faxenabled_legacy">' . _('Legacy');
                    }
                }
                $html .= '
					<!--Detect Faxes-->
					<div class="element-container">
						<div class="row">
							<div class="col-md-12">
								<div class="row">
									<div class="form-group">
										<div class="col-md-3">
											<label class="control-label" for="faxenabled">' . _("Detect Faxes") . '</label>
											<i class="fa fa-question-circle fpbx-help-icon" data-for="faxenabled"></i>
										</div>
										<div class="col-md-9 radioset">
											' . $fdinput . '
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<span id="faxenabled-help" class="help-block fpbx-help-block">' . $fdhelp . '</span>
							</div>
						</div>
					</div>
					<!--END Detect Faxes-->
				';
                $info = engine_getinfo();
                $fdthelp = _("Type of fax detection to use.");
                $fdthelp .= '<ul>';
                $fdthelp .= '<li>' . $dahdi . ': ' . _("use ") . $dahdi . _(" fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ") . $dahdi . '.conf</li>';
                $fdthelp .= '<li>' . _("Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files") . '</li>';
                $fdthelp .= '<li>' . _("NV Fax Detect: Use NV Fax Detection; Requires NV Fax Detect to be installed and recognized by asterisk") . '</li>';
                $fdthelp .= '</ul>';
                $html .= '
				<!--Fax Detection type-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdtype">
					<div class="row">
						<div class="col-md-12">
							<div class="row">
								<div class="form-group">
									<div class="col-md-3">
										<label class="control-label" for="faxdetection">' . _("Fax Detection type") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="faxdetection"></i>
									</div>
									<div class="col-md-9 radioset">
										<input type="radio" name="faxdetection" id="faxdetectiondahdi" value="dahdi" ' . ($fax['detection'] == "dahdi" ? "CHECKED" : "") . ' ' . ($fax_dahdi_faxdetect ? '' : 'disabled') . '>
										<label for="faxdetectiondahdi">' . _("Dahdi") . '</label>
										<input type="radio" name="faxdetection" id="faxdetectionnvfax" value="nvfax" ' . ($fax['detection'] == "nvfax" ? "CHECKED" : "") . ' ' . ($fax_detect['nvfax'] ? '' : 'disabled') . '>
										<label for="faxdetectionnvfax">' . _("NVFax") . '</label>
										<input type="radio" name="faxdetection" id="faxdetectionsip" value="sip" ' . ($fax['detection'] == "sip" ? "CHECKED" : "") . ' ' . ($info['version'] >= "1.6.2" && $fax_sip_faxdetect ? '' : 'disabled') . '>
										<label for="faxdetectionsip">' . _("SIP") . '</label>
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="faxdetection-help" class="help-block fpbx-help-block">' . $fdthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Detection type-->
				';
                if (!$fax['detectionwait']) {
                    $fax['detectionwait'] = 4;
                }
                //default wait time is 4 second
                $fdthelp = _('How long to wait and try to detect fax. Please note that callers to a Dahdi channel will hear ringing for this amount of time (i.e. the system wont "answer" the call, it will just play ringing).');
                $html .= '
				<!--Fax Detection Time-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdtime">
					<div class="row">
						<div class="col-md-12">
							<div class="row">
								<div class="form-group">
									<div class="col-md-3">
										<label class="control-label" for="faxdetectionwait">' . _("Fax Detection Time") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="faxdetectionwait"></i>
									</div>
									<div class="col-md-9">
										<input type="number" min="2" max="11" class="form-control" id="faxdetectionwait" name="faxdetectionwait" value="' . $fax['detectionwait'] . '">
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="faxdetectionwait-help" class="help-block fpbx-help-block">' . $fdthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Detection Time-->
				';
                if (!empty($fax['legacy_email']) || $fax_settings['legacy_mode'] == 'yes') {
                    $fedhelp = _("Address to email faxes to on fax detection.<br />PLEASE NOTE: In this version of FreePBX, you can now set the fax destination from a list of destinations. Extensions/Users can be fax enabled in the user/extension screen and set an email address there. This will create a new destination type that can be selected. To upgrade this option to the full destination list, select YES to Detect Faxes and select a destination. After clicking submit, this route will be upgraded. This Legacy option will no longer be available after the change, it is provided to handle legacy migrations from previous versions of FreePBX only.");
                    $html .= '
					<!--Fax Email Destination-->
					<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fdemail">
						<div class="row">
							<div class="col-md-12">
								<div class="row">
									<div class="form-group">
										<div class="col-md-3">
											<label class="control-label" for="legacy_email"><?php echo _("Fax Email Destination") ?></label>
											<i class="fa fa-question-circle fpbx-help-icon" data-for="legacy_email"></i>
										</div>
										<div class="col-md-9">
											<input type="text" class="form-control" id="legacy_email" name="legacy_email" value="' . $fax['legacy_email'] . '">
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12">
								<span id="legacy_email-help" class="help-block fpbx-help-block">' . $fedhelp . '</span>
							</div>
						</div>
					</div>
					<!--END Fax Email Destination-->
					';
                }
                $faxdesthelp = _('Where to send the faxes');
                $html .= '
				<!--Fax Destination-->
				<div class="element-container ' . ($faxing ? '' : "hidden") . '" id="fddest">
					<div class="row">
						<div class="col-md-12">
							<div class="row">
								<div class="form-group">
									<div class="col-md-3">
										<label class="control-label" for="gotofax">' . _("Fax Destination") . '</label>
										<i class="fa fa-question-circle fpbx-help-icon" data-for="gotofax"></i>
									</div>
									<div class="col-md-9">';
                $html .= $fax_detect ? drawselects(isset($fax['destination']) ? $fax['destination'] : null, 'FAX', false, false) : '';
                $html .= '
									</div>
								</div>
							</div>
						</div>
					</div>
					<div class="row">
						<div class="col-md-12">
							<span id="gotofax-help" class="help-block fpbx-help-block">' . $faxdesthelp . '</span>
						</div>
					</div>
				</div>
				<!--END Fax Destination-->
				<script type="text/javascript">
				$("[name=\'faxenabled\']").change(function(){
					if($(this).val() == \'true\'){
						$("#fdtype").removeClass("hidden");
						$("#fdtime").removeClass("hidden");
						$("#fddest").removeClass("hidden");
					}else{
						$("#fdtype").addClass("hidden");
						$("#fdtime").addClass("hidden");
						$("#fddest").addClass("hidden");
					}
				});
				</script>
				';
            }
            $ret = array();
            $ret[] = array('title' => _("Fax"), 'rawname' => 'fax', 'content' => $html);
            return $ret;
        }
    }
Esempio n. 3
0
 /**
  * @verb GET
  * @returns - list of fax related modules that may be installed
  * @uri /fax/detect
  */
 function get_fax_detect($params)
 {
     return fax_detect();
 }
Esempio 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.
//
$fax = fax_get_settings();
$fax_detect = fax_detect();
$trans_rates = array('9600' => '9600', '12000' => '12000', '14400' => '14400');
$minrateopts = $maxrateopts = '';
foreach ($trans_rates as $rate) {
    $minrateopts .= '<option value=' . $rate . ' ' . ($rate == $fax['minrate'] ? "SELECTED" : "") . '>' . $rate . '</option>';
    $maxrateopts .= '<option value=' . $rate . ' ' . ($rate == $fax['maxrate'] ? "SELECTED" : "") . '>' . $rate . '</option>';
}
$aghtml = '';
if (!$fax_detect['module']) {
    $aghtml = '
		<!--Always Generate Detection Code-->
		<div class="element-container">
			<div class="row">
				<div class="col-md-12">
					<div class="row">
						<div class="form-group">
							<div class="col-md-3">
								<label class="control-label" for="force_detection">' . _("Always Generate Detection Code") . '</label>
								<i class="fa fa-question-circle fpbx-help-icon" data-for="force_detection"></i>
							</div>
							<div class="col-md-9 radioset">
								<input type="radio" class="form-control" id="force_detection_yes" name="force_detection" value="yes"' . ($fax['force_detection'] == 'yes' ? 'checked' : '') . '>
								<label for="force_detection_yes">' . _("Yes") . '</label>
								<input type="radio" class="form-control" id="force_detection_no" name="force_detection" value="no" ' . ($fax['force_detection'] == 'no' ? 'checked' : '') . '>
								<label for="force_detection_no">' . _("No") . '</label>