Beispiel #1
0
 function generateConf($file)
 {
     global $version;
     global $amp_conf;
     switch ($file) {
         case 'sip_general_additional.conf':
             return $this->generate_sip_general_additional($version);
             break;
         case 'sip_additional.conf':
             return $this->generate_sip_additional($version);
             break;
         case 'sip_registrations.conf':
             return $this->generate_sip_registrations($version);
             break;
         case 'sip_notify_additional.conf':
             return $this->generate_sip_notify_additional($version);
             break;
         case 'iax_general_additional.conf':
             return $this->generate_iax_general_additional($version);
             break;
         case 'iax_additional.conf':
             return $this->generate_iax_additional($version);
             break;
         case 'iax_registrations.conf':
             return $this->generate_iax_registrations($version);
             break;
         case 'chan_dahdi_additional.conf':
             if (ast_with_dahdi() && $amp_conf['ZAP2DAHDICOMPAT']) {
                 return $this->generate_zapata_additional($version, 'dahdi') . $this->generate_zapata_additional($version);
             } else {
                 return $this->generate_zapata_additional($version, 'dahdi');
             }
             break;
         case 'zapata_additional.conf':
             return $this->generate_zapata_additional($version);
             break;
         case 'features_general_additional.conf':
             return $this->generate_featuregeneral_additional($version);
             break;
         case 'features_applicationmap_additional.conf':
             return $this->generate_applicationmap_additional($version);
             break;
         case 'features_featuremap_additional.conf':
             return $this->generate_featuremap_additional($version);
             break;
     }
 }
Beispiel #2
0
#!/usr/bin/php -q
<?php 
//include bootstrap
$restrict_mods = true;
$bootstrap_settings['freepbx_auth'] = false;
if (!@(include_once getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
    include_once '/etc/asterisk/freepbx.conf';
}
// If set to nointercom then don't generate any hints
//
$intercom_code = isset($argv[1]) ? $argv[1] : '';
$campon_toggle = isset($argv[2]) ? $argv[2] : '';
$dnd_mode = isset($argv[3]) ? $argv[3] : '';
$ast_with_dahdi = ast_with_dahdi();
$var = $astman->database_show('AMPUSER');
foreach ($var as $key => $value) {
    $myvar = explode('/', trim($key, '/'));
    $user_hash[$myvar[1]] = true;
}
foreach (array_keys($user_hash) as $user) {
    if ($user != 'none' && $user != '') {
        $devices = get_devices($user);
        //debug("Set hints for user: $user for devices:  ".$devices,5);
        set_hint($user, $devices);
    }
}
//---------------------------------------------------------------------
// Set the hint for a user based on the devices in their AMPUSER object
//
function set_hint($user, $devices)
{
Beispiel #3
0
function core_hint_get($account)
{
    global $astman;
    static $hintCache;
    if (isset($hintCache[$account])) {
        return $hintCache[$account];
    }
    $chan_dahdi = ast_with_dahdi();
    // We should always check the AMPUSER in case they logged into a device
    // but we will fall back to the old methond if $astman not open although
    // I'm pretty sure everything else will puke anyhow if not running
    //
    if ($astman) {
        $device = $astman->database_get("AMPUSER", $account . "/device");
        $device_arr = explode('&', $device);
        $sql = "SELECT dial from devices where id in ('" . implode("','", $device_arr) . "')";
    } else {
        $sql = "SELECT dial from devices where user = '******'";
    }
    $results = sql($sql, "getAll", DB_FETCHMODE_ASSOC);
    //create an array of strings
    if (is_array($results)) {
        foreach ($results as $result) {
            if ($chan_dahdi) {
                $dial[] = str_replace('ZAP', 'DAHDI', $result['dial']);
            } else {
                $dial[] = $result['dial'];
            }
        }
    }
    //create a string with & delimiter
    if (isset($dial) && is_array($dial)) {
        $hint = implode($dial, "&");
    } else {
        if (isset($results[0]['dial'])) {
            $hint = $results[0]['dial'];
        } else {
            $hint = null;
        }
    }
    $hintCache[$account] = $hint;
    return $hint;
}
Beispiel #4
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;
        }
    }
Beispiel #5
0
     $dialoutprefix = "";
     if ($tech == 'zap' || $tech == 'dahdi') {
         $channelid = 'g0';
     } else {
         $channelid = '';
     }
     // only for iax2/sip
     $peerdetails = "host=***provider ip address***\nusername=***userid***\nsecret=***password***\ntype=peer";
     $usercontext = "";
     $userconfig = "secret=***password***\ntype=user\ncontext=from-trunk";
     $register = "";
     $localpattern = "NXXXXXX";
     $lddialprefix = "1";
     $areacode = "";
     $upper_tech = strtoupper($tech);
     echo "<h2>" . sprintf(_("Add %s Trunk"), $upper_tech) . ($upper_tech == 'ZAP' && ast_with_dahdi() ? " (" . _("DAHDI compatibility mode") . ")" : "") . "</h2>";
 }
 if (!isset($dialpattern_array)) {
     $dialpattern_array = array();
 }
 switch ($tech) {
     case 'dundi':
         $helptext = _('FreePBX offers limited support for DUNDi trunks and additional manual configuration is required. The trunk name should correspond to the [mappings] section of the remote dundi.conf systems. For example, you may have a mapping on the remote system, and corresponding configurations in dundi.conf locally, that looks as follows:<br /><br />[mappings]<br />priv => dundi-extens,0,IAX2,priv:${SECRET}@218.23.42.26/${NUMBER},nopartial<br /><br />In this example, you would create this trunk and name it priv. You would then create the corresponding IAX2 trunk with proper settings to work with DUNDi. This can be done by making an IAX2 trunk in FreePBX or by using the iax_custom.conf file.<br />The dundi-extens context in this example must be created in extensions_custom.conf. This can simply include contexts such as ext-local, ext-intercom-users, ext-paging and so forth to provide access to the corresponding extensions and features provided by these various contexts and generated by FreePBX.');
         break;
     case 'sip':
         break;
     default:
         $helptext = '';
 }
 if ($helptext != '') {
     if ($extdisplay) {
Beispiel #6
0
//    FreePBX is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with FreePBX.  If not, see <http://www.gnu.org/licenses/>.
//
//    Copyright (C) 2006 Astrogen LLC
//
$dispnum = 'asteriskinfo';
//used for switch on config.php
$tabindex = 0;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : 'summary';
$chan_dahdi = ast_with_dahdi();
$modesummary = _("Summary");
$moderegistries = _("Registries");
$modechannels = _("Channels");
$modepeers = _("Peers");
$modesip = _("Sip Info");
$modeiax = _("IAX Info");
$modeconferences = _("Conferences");
$modesubscriptions = _("Subscriptions");
$modeall = _("Full Report");
$uptime = _("Uptime");
$activechannels = _("Active Channel(s)");
$sipchannels = _("Sip Channel(s)");
$iax2channels = _("IAX2 Channel(s)");
$iax2peers = _("IAX2 Peers");
$sipregistry = _("Sip Registry");
Beispiel #7
0
function core_devices_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    if ($tech_hardware == 'virtual') {
        return true;
    }
    // Init vars from $_REQUEST[]
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    if ($action == 'del') {
        // Deleted
        if ($display != 'extensions') {
            $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay . ' ' . _("deleted"), false));
        }
    } elseif ($extdisplay == '' && $tech_hardware == '') {
        // Adding
        if ($display != 'extensions') {
            $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add Device")), 0);
        } else {
            $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add an Extension")), 0);
        }
        $currentcomponent->addguielem('_top', new gui_label('instructions', _("Please select your Device below then click Submit")));
        $currentcomponent->addguielem('Device', new gui_selectbox('tech_hardware', $currentcomponent->getoptlist('devicelist'), '', _("Device"), '', false));
    } else {
        $deviceInfo = array();
        if ($extdisplay) {
            // Editing
            $deviceInfo = core_devices_get($extdisplay);
            if ($display != 'extensions') {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Device") . ": {$extdisplay}", false), 0);
                $delURL = '?' . $_SERVER['QUERY_STRING'] . '&action=del';
                $tlabel = sprintf(_("Delete Device %s"), $extdisplay);
                $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/telephone_delete.png"/>&nbsp;' . $tlabel . '</span>';
                $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                if ($deviceInfo['device_user'] != 'none') {
                    $editURL = '?display=users&skip=0&extdisplay=' . $deviceInfo['user'];
                    $tlabel = $deviceInfo['devicetype'] == 'adhoc' ? sprintf(_("Edit Default User: %s"), $deviceInfo['user']) : sprintf(_("Edit Fixed User: %s"), $deviceInfo['user']);
                    $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_edit.png"/>&nbsp;' . $tlabel . '</span>';
                    $currentcomponent->addguielem('_top', new gui_link('edit_user', $label, $editURL, true, false), 0);
                }
            }
        } else {
            $tmparr = explode('_', $tech_hardware);
            $deviceInfo['tech'] = $tmparr[0];
            $deviceInfo['hardware'] = $tmparr[1];
            unset($tmparr);
            if ($display != 'extensions') {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', sprintf(_("Add %s Device"), strtoupper($deviceInfo['tech']))), 0);
            } else {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', sprintf(_("Add %s Extension"), strtoupper($deviceInfo['tech']))), 0);
            }
        }
        // Ensure they exist before the extract
        $devinfo_description = $devinfo_emergency_cid = null;
        $devinfo_devicetype = $devinfo_user = $devinfo_hardware = null;
        $devinfo_tech = null;
        if (is_array($deviceInfo)) {
            extract($deviceInfo, EXTR_PREFIX_ALL, 'devinfo');
        }
        // Setup vars for use in the gui later on
        $fc_logon = featurecodes_getFeatureCode('core', 'userlogon');
        $fc_logoff = featurecodes_getFeatureCode('core', 'userlogoff');
        $msgInvalidDevID = _("Please enter a device id.");
        $msgInvalidDevDesc = _("Please enter a valid Description for this device");
        $msgInvalidEmergCID = _("Please enter a valid Emergency CID");
        $msgInvalidExtNum = _("Please enter a valid extension number.");
        // Actual gui
        $currentcomponent->addguielem('_top', new gui_hidden('action', $extdisplay ? 'edit' : 'add'));
        $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
        if ($display != 'extensions') {
            $section = _("Device Info");
            if ($extdisplay) {
                // Editing
                $currentcomponent->addguielem($section, new gui_hidden('deviceid', $extdisplay));
            } else {
                // Adding
                $currentcomponent->addguielem($section, new gui_textbox('deviceid', $extdisplay, _("Device ID"), _("Give your device a unique integer ID.  The device will use this ID to authenticate to the system."), '!isInteger()', $msgInvalidDevID, false));
            }
            $currentcomponent->addguielem($section, new gui_textbox('description', $devinfo_description, _("Description"), _("The CallerID name for this device will be set to this description until it is logged into."), '!isAlphanumeric() || isWhitespace()', $msgInvalidDevDesc, false));
            $currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, _("Emergency CID"), _("This CallerID will always be set when dialing out an Outbound Route flagged as Emergency.  The Emergency CID overrides all other CallerID settings."), '!isCallerID()', $msgInvalidEmergCID));
            $currentcomponent->addguielem($section, new gui_selectbox('devicetype', $currentcomponent->getoptlist('devicetypelist'), $devinfo_devicetype, _("Device Type"), _("Devices can be fixed or adhoc. Fixed devices are always associated to the same extension/user. Adhoc devices can be logged into and logged out of by users.") . ' ' . $fc_logon . ' ' . _("logs into a device.") . ' ' . $fc_logoff . ' ' . _("logs out of a device."), false));
            $currentcomponent->addguielem($section, new gui_selectbox('deviceuser', $currentcomponent->getoptlist('deviceuserlist'), $devinfo_user, _("Default User"), _("Fixed devices will always mapped to this user.  Adhoc devices will be mapped to this user by default.<br><br>If selecting 'New User', a new User Extension of the same Device ID will be set as the Default User."), false));
        } else {
            $section = _("Extension Options");
            $currentcomponent->addguielem($section, new gui_textbox('emergency_cid', $devinfo_emergency_cid, _("Emergency CID"), _("This CallerID will always be set when dialing out an Outbound Route flagged as Emergency.  The Emergency CID overrides all other CallerID settings."), '!isCallerID()', $msgInvalidEmergCID));
        }
        $currentcomponent->addguielem($section, new gui_hidden('tech', $devinfo_tech));
        $currentcomponent->addguielem($section, new gui_hidden('hardware', $devinfo_hardware));
        if ($devinfo_tech && $devinfo_tech != "virtual") {
            $section = _("Device Options");
            $devinfo_techd = $devinfo_tech == 'sip' ? 'CHAN_SIP' : strtoupper($devinfo_tech);
            if (FreePBX::Modules()->moduleHasMethod("sipsettings", "getBinds")) {
                $out = FreePBX::Sipsettings()->getBinds();
                foreach ($out[$devinfo_tech] as $ip => $data1) {
                    foreach ($data1 as $protocol => $port) {
                        $pport .= $ip . ":" . $port . ', ';
                    }
                }
                $pport = rtrim($pport, ", ");
            } else {
                $pport = '';
            }
            $extrac = !empty($pport) ? sprintf(_('listening on <strong>%s</strong>'), $pport) : '';
            $device_uses = sprintf(_("This device uses %s technology %s"), "<strong>" . $devinfo_techd . "</strong>", $extrac) . (strtoupper($devinfo_tech) == 'ZAP' && ast_with_dahdi() ? " (" . _("Via DAHDi compatibility mode") . ")" : "");
            $currentcomponent->addguielem($section, new gui_label('techlabel', '<div class="alert alert-info" role="alert" style="width:100%">' . $device_uses . '</div>'), 4);
            // We need to scream loudly if this device is using a channel driver that's disabled.
            if ($devinfo_tech == "pjsip" || $devinfo_tech == "sip") {
                $sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER');
                if ($sipdriver != "both") {
                    // OK, one is disabled.
                    if ($devinfo_tech == "sip") {
                        $iwant = "chan_sip";
                    } else {
                        $iwant = "chan_pjsip";
                    }
                    if ($iwant != $sipdriver) {
                        // Poot.
                        $err = sprintf(_("<strong>CRITICAL ERROR!</strong> Required Service %s is disabled! This device is unusable!"), strtoupper($iwant));
                        $currentcomponent->addguielem($section, new gui_label('techerrlabel', $err), 3);
                    }
                }
            }
            $devopts = $currentcomponent->getgeneralarrayitem('devtechs', $devinfo_tech);
            if (is_array($devopts)) {
                foreach ($devopts as $devopt => $devoptarr) {
                    $devopname = 'devinfo_' . $devopt;
                    $devoptcurrent = isset(${$devopname}) ? ${$devopname} : $devoptarr['value'];
                    $devoptjs = isset($devoptarr['jsvalidation']) ? $devoptarr['jsvalidation'] : '';
                    $devoptfailmsg = isset($devoptarr['failvalidationmsg']) ? $devoptarr['failvalidationmsg'] : '';
                    $devdisable = isset($devoptarr['disable']) ? $devoptarr['disable'] : false;
                    $devonchange = isset($devoptarr['onchange']) ? $devoptarr['onchange'] : '';
                    $prompttext = isset($devoptarr['prompttext']) ? $devoptarr['prompttext'] : $devopt;
                    $hidden = isset($devoptarr['hidden']) ? $devoptarr['hidden'] : false;
                    $type = isset($devoptarr['type']) ? $devoptarr['type'] : (isset($devoptarr['select']) ? 'select' : 'text');
                    $text = isset($devoptarr['text']) ? $devoptarr['text'] : '';
                    // We compare the existing secret against what might be in the put to detect changes when validating
                    if ($devopt == "secret") {
                        $currentcomponent->addguielem($section, new gui_hidden($devopname . "_origional", $devoptcurrent), 4);
                        if ($devoptcurrent == '' && empty($extdisplay)) {
                            $devoptcurrent = md5(uniqid());
                        }
                    }
                    if (!$hidden && ($devoptarr['level'] == 0 || $amp_conf['ALWAYS_SHOW_DEVICE_DETAILS'] && $devoptarr['level'] < 2 || $extdisplay != '')) {
                        // editing to show advanced as well
                        // Added optional selectbox to enable the unsupported misdn module
                        $tooltip = isset($devoptarr['tt']) ? $devoptarr['tt'] : '';
                        if ($type == 'select') {
                            $currentcomponent->addguielem($section, new gui_selectbox($devopname, $devoptarr['select'], $devoptcurrent, $prompttext, $tooltip, false, $devonchange, $devdisable), 4);
                        } elseif ($type == 'text') {
                            $currentcomponent->addguielem($section, new gui_textbox($devopname, $devoptcurrent, $prompttext, $tooltip, $devoptjs, $devoptfailmsg, true, 0, $devdisable), 4);
                        } elseif ($type == 'button') {
                            $currentcomponent->addguielem($section, new gui_button($devopname, $devoptcurrent, $prompttext, $tooltip, $text, $devoptjs, $devdisable), 4);
                        }
                    } else {
                        // add so only basic
                        $currentcomponent->addguielem($section, new gui_hidden($devopname, $devoptcurrent), 4);
                    }
                }
            }
        }
    }
}
Beispiel #8
0
function fax_hook_core($viewing_itemid, $target_menuid)
{
    //hmm, not sure why engine_getinfo() isnt being called here?! should probobly read: $info=engine_getinfo();
    //this is what serves fax code to inbound routing
    $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 ($type != 'setup') {
        if (!$extension && !$cidnum) {
            //set $extension,$cidnum if we dont already have them
            $opts = explode('/', $extdisplay);
            $extension = $opts['0'];
            $cidnum = $opts['1'];
        }
        $fax = fax_get_incoming($extension, $cidnum);
    } else {
        $fax = null;
    }
    $html = '';
    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>';
        $html .= '<tr><td colspan="2"><h5>';
        $html .= _('Fax Detect');
        $html .= '<hr></h5></td></tr>';
        $html .= '<tr>';
        $html .= '<td><a href="#" class="info">';
        $html .= _("Detect Faxes") . '<span>' . _("Attempt to detect faxes on this DID.") . "<ul><li>" . _("No: No attempts are made to auto-determine the call type; all calls sent to destination below. Use this option if this DID is used exclusively for voice OR fax.") . "</li><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) {
            $html .= '<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>';
        }
        $html .= '</ul></span></a>:</td>';
        //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;}";
            $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED />No';
            $html .= '<input type="radio" name="faxenabled" value="true"  onclick="' . $js . '"/>Yes</td></tr>';
            $html .= '</table><table>';
        } 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
             */
            if ($fax['legacy_email'] === null && $fax_settings['legacy_mode'] == 'no') {
                $jsno = "\$('.faxdetect').slideUp();";
                $jsyes = "\$('.faxdetect').slideDown();";
            } else {
                $jsno = "\$('.faxdetect').slideUp();\$('.legacyemail').slideUp();";
                $jsyes = "\$('.legacyemail').slideUp('400',function(){\n\t\t\t\t\t\t\t\$('.faxdetect').slideDown()\n\t\t\t\t\t\t});";
                $jslegacy = "\$('.faxdest27').slideUp('400',function(){ \n\t\t\t\t\t\t\t\t\$('.faxdetect, .legacyemail').not(\$('.faxdest27')).slideDown();\n\t\t\t\t\t\t});";
            }
            $html .= '<td><input type="radio" name="faxenabled" value="false" CHECKED onclick="' . $jsno . '"/>No';
            $html .= '<input type="radio" name="faxenabled" value="true" ' . ($fax ? 'CHECKED' : '') . ' onclick="' . $jsyes . '"/>Yes';
            if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
                $html .= '<input type="radio" name="faxenabled" value="legacy"' . ($fax['legacy_email'] !== null ? ' CHECKED ' : '') . 'onclick="' . $jslegacy . '"/>Legacy';
            }
            $html .= '</td></tr>';
            $html .= '</table>';
        }
        //fax detection+destinations, hidden if there is fax is disabled
        $html .= '<table class=faxdetect ' . ($fax ? '' : 'style="display: none;"') . '>';
        $info = engine_getinfo();
        $html .= '<tr><td width="156px"><a href="#" class="info">' . _('Fax Detection type') . '<span>' . _("Type of fax detection to use.") . "<ul><li>" . $dahdi . ": " . _("use ") . $dahdi . _(" fax detection; requires 'faxdetect=' to be set to 'incoming' or 'both' in ") . $dahdi . ".conf</li><li>" . _("Sip: use sip fax detection (t38). Requires asterisk 1.6.2 or greater and 'faxdetect=yes' in the sip config files") . "</li><li>" . _("NV Fax Detect: Use NV Fax Detection; Requires NV Fax Detect to be installed and recognized by asterisk") . "</li></ul>" . '.</span></a>:</td>';
        $html .= '<td><select name="faxdetection" tabindex="' . ++$tabindex . '">';
        //$html.='<option value="Auto"'.($faxdetection == 'auto' ? 'SELECTED' : '').'>'. _("Auto").'</option>';<li>Auto: allow the system to chose the best fax detection method</li>
        $html .= '<option value="dahdi" ' . ($fax['detection'] == 'dahdi' ? 'SELECTED' : '') . ' ' . ($fax_dahdi_faxdetect ? '' : 'disabled') . '>' . $dahdi . '</option>';
        $html .= '<option value="nvfax"' . ($fax['detection'] == 'nvfax' ? 'SELECTED' : '') . ($fax_detect['nvfax'] ? '' : 'disabled') . '>' . _("NVFax") . '</option>';
        $html .= '<option value="sip" ' . ($fax['detection'] == 'sip' ? 'SELECTED' : '') . ' ' . ($info['version'] >= "1.6.2" && $fax_sip_faxdetect ? '' : 'disabled') . '>' . _("Sip") . '</option>';
        $html .= '</select></td></tr>';
        $html .= '<tr><td><a href="#" class="info">' . _("Fax Detection Time") . '<span>' . _('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)') . '.</span></a>:</td>';
        $html .= '<td><select name="faxdetectionwait" tabindex="' . ++$tabindex . '">';
        if (!$fax['detectionwait']) {
            $fax['detectionwait'] = 4;
        }
        //default wait time is 4 second
        for ($i = 2; $i < 11; $i++) {
            $html .= '<option value="' . $i . '" ' . ($fax['detectionwait'] == $i ? 'SELECTED' : '') . '>' . $i . '</option>';
        }
        $html .= '</select></td></tr>';
        if ($fax['legacy_email'] !== null || $fax_settings['legacy_mode'] == 'yes') {
            $html .= '</table>';
            $html .= '<table class="legacyemail"' . ($fax['legacy_email'] === null ? ' style="display: none;"' : '') . '>';
            $html .= '<tr ><td><a href="#" class="info">' . _("Fax Email Destination") . '<span>' . _('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.') . '.</span></a>:</td>';
            $html .= '<td><input name="legacy_email" value="' . $fax['legacy_email'] . '"></td></tr>';
            $html .= '</table>';
            $html .= '<table class="faxdest27 faxdetect" style="display: none" >';
        }
        $html .= '<tr class="faxdest"><td><a href="#" class="info">' . _("Fax Destination") . '<span>' . _('Where to send the call if we detect that its a fax') . '.</span></a>:</td>';
        $html .= '<td>';
        $html .= $fax_detect ? drawselects(isset($fax['destination']) ? $fax['destination'] : null, 'FAX', false, false) : '';
        $html .= '</td></tr></table>';
        $html .= '<table>';
    }
    return $html;
}