Esempio n. 1
0
 public function usermanShowPage()
 {
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'showuser':
                 $user = $this->getUserByID($_REQUEST['user']);
                 if (isset($_POST['submit']) || isset($_POST['submittype'])) {
                     $this->processModuleConfigPages($user);
                     $this->expireUserSessions($_REQUEST['user']);
                 }
                 if (!empty($_REQUEST['deletesession'])) {
                     $this->expireUserSession($_REQUEST['deletesession']);
                     $this->setUsermanMessage(_('Deleted User Session'), 'success');
                 }
                 $fpbxusers = array();
                 $cul = array();
                 foreach (core_users_list() as $list) {
                     $cul[$list[0]] = array("name" => $list[1]);
                 }
                 $sassigned = $this->getSetting($user['username'], 'Settings', 'assigned');
                 $sassigned = !empty($sassigned) ? $sassigned : array();
                 foreach ($user['assigned'] as $assigned) {
                     $fpbxusers[] = array("ext" => $assigned, "data" => $cul[$assigned], "selected" => in_array($assigned, $sassigned));
                 }
                 return load_view(dirname(__FILE__) . '/views/users_hook.php', array("fpbxusers" => $fpbxusers, "mHtml" => $this->constructModuleConfigPages($user), "user" => $user, "allowLogin" => FreePBX::create()->Userman->getModuleSettingByID($_REQUEST['user'], 'ucp|Global', 'allowLogin'), "sessions" => $this->getUserSessions($user['id'])));
                 break;
             case 'adduser':
                 if (isset($_POST['submit'])) {
                     $user = $this->getUserByUsername($_REQUEST['username']);
                     $this->processModuleConfigPages($user);
                 }
                 $fpbxusers = array();
                 $cul = array();
                 foreach (core_users_list() as $list) {
                     $cul[$list[0]] = array("name" => $list[1]);
                 }
                 return load_view(dirname(__FILE__) . '/views/users_hook.php', array("fpbxusers" => $fpbxusers, "mHtml" => $this->constructModuleConfigPages($user), "user" => array(), "allowLogin" => true, "sessions" => array()));
                 break;
             default:
                 break;
         }
     }
 }
Esempio n. 2
0
 /**
  * get the Admin display in UCP
  * @param array $user The user array
  */
 public function getUCPAdminDisplay($user)
 {
     $fpbxusers = array();
     $cul = array();
     foreach (core_users_list() as $list) {
         $cul[$list[0]] = array("name" => $list[1], "vmcontext" => $list[2]);
     }
     $download = $this->FreePBX->Ucp->getSetting($user['username'], 'Cdr', 'download');
     $playback = $this->FreePBX->Ucp->getSetting($user['username'], 'Cdr', 'playback');
     $download = is_null($download) ? true : $download;
     $playback = is_null($playback) ? true : $playback;
     $cdrassigned = $this->FreePBX->Ucp->getSetting($user['username'], 'Cdr', 'assigned');
     $cdrassigned = !empty($cdrassigned) ? $cdrassigned : array();
     foreach ($user['assigned'] as $assigned) {
         $fpbxusers[] = array("ext" => $assigned, "data" => $cul[$assigned], "selected" => in_array($assigned, $cdrassigned));
     }
     $html[0]['description'] = '<a href="#" class="info">' . _("Allowed CDR") . ':<span>' . _("These are the assigned and active extensions which will show up for this user to control and edit in UCP") . '</span></a>';
     $html[0]['content'] = load_view(dirname(__FILE__) . "/views/ucp_config.php", array("fpbxusers" => $fpbxusers));
     $html[1]['description'] = '<a href="#" class="info">' . _("Allow CDR Playback") . ':<span>' . _("Allow this user to playback recordings in UCP") . '</span></a>';
     $html[1]['content'] = load_view(dirname(__FILE__) . "/views/ucp_config_playback.php", array("playback" => $playback));
     $html[2]['description'] = '<a href="#" class="info">' . _("Allow CDR Downloads") . ':<span>' . _("Allow users to download recordings in UCP") . '</span></a>';
     $html[2]['content'] = load_view(dirname(__FILE__) . "/views/ucp_config_downloads.php", array("download" => $download));
     return $html;
 }
Esempio n. 3
0
<?php

/* $Id: page.extensions.php 7630 2009-05-03 08:37:52Z mickecarlsson $ */
//This file is part of FreePBX.
//
//    FreePBX is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 2 of the License, or
//    (at your option) any later version.
//
//    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) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
//
?>

<div class="rnav">
<?php 
$extens = core_users_list();
$description = _("Extension");
drawListMenu($extens, $skip, $type, $display, $extdisplay, $description);
?>
	<br />
</div>
Esempio n. 4
0
/**
 * function generate_module_repo_url
 * short create array of full URLs to get a file from repo
 * use this function to generate an array of URLs for all configured REPOs
 * @author Philippe Lindheimer
 *
 * @pram string
 * @returns string
 */
function generate_module_repo_url($path, $add_options = false)
{
    global $db;
    global $amp_conf;
    $urls = array();
    if ($add_options) {
        $firstinstall = false;
        $type = null;
        $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
        $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
        // if not set so this is a first time install
        // get a new hash to account for first time install
        //
        if (!isset($result['data']) || trim($result['data']) == "") {
            $firstinstall = true;
            $install_hash = _module_generate_unique_id();
            $installid = $install_hash['uniqueid'];
            $type = $install_hash['type'];
            // save the hash so we remeber this is a first time install
            //
            $data4sql = $db->escapeSimple($installid);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
            $data4sql = $db->escapeSimple($type);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
            // Not a first time so save the queried hash and check if there is a type set
            //
        } else {
            $installid = $result['data'];
            $sql = "SELECT * FROM module_xml WHERE id = 'type'";
            $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
            if (isset($result['data']) && trim($result['data']) != "") {
                $type = $result['data'];
            }
        }
        // Now we have the id and know if this is a firstime install so we can get the announcement
        //
        $options = "?installid=" . urlencode($installid);
        if (trim($type) != "") {
            $options .= "&type=" . urlencode($type);
        }
        if ($firstinstall) {
            $options .= "&firstinstall=yes";
        }
        // We check specifically for false because evenif blank it means the file
        // was there so we want module.xml to do appropriate actions
        $brandid = _module_brandid();
        if ($brandid !== false) {
            $options .= "&brandid=" . urlencode($brandid);
        }
        $deploymentid = _module_deploymentid();
        if ($deploymentid !== false) {
            $options .= "&depolymentid=" . urlencode($deploymentid);
        }
        $engver = engine_getinfo();
        if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
            $options .= "&astver=" . urlencode($engver['version']);
        } else {
            $options .= "&astver=" . urlencode($engver['raw']);
        }
        $options .= "&phpver=" . urlencode(phpversion());
        $distro_info = _module_distro_id();
        $options .= "&distro=" . urlencode($distro_info['pbx_type']);
        $options .= "&distrover=" . urlencode($distro_info['pbx_version']);
        $options .= "&fpbxver=" . urlencode(getversion());
        if (function_exists('core_users_list')) {
            $options .= "&ucount=" . urlencode(count(core_users_list()));
        }
        $path .= $options;
        // Other modules may need to add 'get' paramters to the call to the repo. Check and add them
        // here if we are adding paramters. The module should return an array of key/value pairs each of which
        // is to be appended to the GET parameters. The variable name will be prepended with the module name
        // when sent.
        //
        $repo_params = array();
        foreach (mod_func_iterator('module_repo_parameters_callback', $path) as $mod => $res) {
            if (is_array($res)) {
                foreach ($res as $p => $v) {
                    $path .= '&' . urlencode($mod) . '_' . urlencode($p) . '=' . urlencode($v);
                }
            }
        }
    }
    $repos = explode(',', $amp_conf['MODULE_REPO']);
    foreach ($repos as $repo) {
        $urls[] = $repo . $path;
    }
    return $urls;
}
Esempio n. 5
0
 public function myShowPage()
 {
     if (!function_exists('core_users_list')) {
         return _("Module Core is disabled. Please enable it");
     }
     $module_hook = \moduleHook::create();
     $mods = $this->FreePBX->Hooks->processHooks();
     $moduleHtml = '';
     foreach ($mods as $mod) {
         $moduleHtml .= $mod;
     }
     $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
     $html = '';
     $users = $this->getAllUsers();
     $html .= load_view(dirname(__FILE__) . '/views/rnav.php', array("users" => $users));
     switch ($action) {
         case 'showuser':
         case 'adduser':
             if ($action == 'showuser' && !empty($_REQUEST['user'])) {
                 $user = $this->getUserByID($_REQUEST['user']);
                 $assigned = $this->getGlobalSettingByID($_REQUEST['user'], 'assigned');
                 $assigned = !empty($assigned) ? $assigned : array();
                 $default = $user['default_extension'];
             } else {
                 $user = array();
                 $assigned = array();
                 $default = null;
             }
             $fpbxusers = array();
             $dfpbxusers = array();
             $cul = array();
             foreach (core_users_list() as $list) {
                 $cul[$list[0]] = array("name" => $list[1], "vmcontext" => $list[2]);
             }
             foreach ($cul as $e => $u) {
                 $fpbxusers[] = array("ext" => $e, "name" => $u['name'], "selected" => in_array($e, $assigned));
             }
             $iuext = $this->getAllInUseExtensions();
             $dfpbxusers[] = array("ext" => 'none', "name" => 'none', "selected" => false);
             foreach ($cul as $e => $u) {
                 if ($e != $default && in_array($e, $iuext)) {
                     continue;
                 }
                 $dfpbxusers[] = array("ext" => $e, "name" => $u['name'], "selected" => $e == $default);
             }
             $html .= load_view(dirname(__FILE__) . '/views/users.php', array("dfpbxusers" => $dfpbxusers, "fpbxusers" => $fpbxusers, "moduleHtml" => $moduleHtml, "hookHtml" => $module_hook->hookHtml, "user" => $user, "message" => $this->message));
             break;
         case 'general':
             $html .= load_view(dirname(__FILE__) . '/views/general.php', array("subject" => $this->getGlobalsetting('emailsubject'), "email" => $this->getGlobalsetting('emailbody'), "message" => $this->message, "brand" => $this->brand));
             break;
         default:
             $html .= load_view(dirname(__FILE__) . '/views/welcome.php', array());
             break;
     }
     return $html;
 }
Esempio n. 6
0
					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-12">
					<span id="audio_label-help" class="help-block fpbx-help-block">' . _("Play this message to the caller so they can confirm they have dialed the proper voice mail group number, or have the system simply read the group number.") . '</span>
				</div>
			</div>
		</div>
		<!--END Audio Label-->
	';
} else {
    $default = isset($audio_label) ? $audio_label : -1;
    $alabelhtml = '<input type="hidden" name="audio_label" value="' . $default . '">';
}
$results = core_users_list();
if (!is_array($results)) {
    $results = array();
}
foreach ($results as $result) {
    if ($result[2] != 'novm') {
        $extenlopts .= '<option value="' . $result[0] . '" ';
        if (array_search($result[0], $grplist) !== false) {
            $extenlopts .= ' SELECTED ';
        }
        $extenlopts .= '>' . $result[0] . ' (' . $result[1] . ')</option>';
    }
}
echo $usagehtml;
?>
Esempio n. 7
0
 /**
  * @verb GET
  * @return - a list of users
  * @uri /core/users
  */
 function get_users()
 {
     return core_users_list();
 }
Esempio n. 8
0
function core_devices_configpageinit($dispnum)
{
    global $currentcomponent;
    global $amp_conf;
    if ($dispnum == 'devices' || $dispnum == 'extensions') {
        // Setup arrays for device types
        $currentcomponent->addgeneralarray('devtechs');
        // Some errors for the validation bits
        $msgInvalidDTMFMODE = _("Please enter the dtmfmode for this device");
        $msgInvalidChannel = _("Please enter the channel for this device");
        $msgConfirmSecret = _("You have not entered a Secret for this device, although this is possible it is generally bad practice to not assign a Secret to a device. Are you sure you want to leave the Secret empty?");
        $msgInvalidSecret = _("Please enter a Secret for this device");
        // zap
        $tmparr = array();
        $tmparr['channel'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel);
        $tmparr['context'] = array('value' => 'from-internal', 'level' => 1);
        $tmparr['immediate'] = array('value' => 'no', 'level' => 1);
        $tmparr['signalling'] = array('value' => 'fxo_ks', 'level' => 1);
        $tmparr['echocancel'] = array('value' => 'yes', 'level' => 1);
        $tmparr['echocancelwhenbridged'] = array('value' => 'no', 'level' => 1);
        $tmparr['echotraining'] = array('value' => '800', 'level' => 1);
        $tmparr['busydetect'] = array('value' => 'no', 'level' => 1);
        $tmparr['busycount'] = array('value' => '7', 'level' => 1);
        $tmparr['callprogress'] = array('value' => 'no', 'level' => 1);
        $tmparr['dial'] = array('value' => '', 'level' => 1);
        $tmparr['accountcode'] = array('value' => '', 'level' => 1);
        $tmparr['callgroup'] = array('value' => '', 'level' => 1);
        $tmparr['pickupgroup'] = array('value' => '', 'level' => 1);
        $tmparr['mailbox'] = array('value' => '', 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'zap', $tmparr);
        unset($tmparr);
        // dahdi
        $tmparr = array();
        $tmparr['channel'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel);
        $tmparr['context'] = array('value' => 'from-internal', 'level' => 1);
        $tmparr['immediate'] = array('value' => 'no', 'level' => 1);
        $tmparr['signalling'] = array('value' => 'fxo_ks', 'level' => 1);
        $tmparr['echocancel'] = array('value' => 'yes', 'level' => 1);
        $tmparr['echocancelwhenbridged'] = array('value' => 'no', 'level' => 1);
        $tmparr['echotraining'] = array('value' => '800', 'level' => 1);
        $tmparr['busydetect'] = array('value' => 'no', 'level' => 1);
        $tmparr['busycount'] = array('value' => '7', 'level' => 1);
        $tmparr['callprogress'] = array('value' => 'no', 'level' => 1);
        $tmparr['dial'] = array('value' => '', 'level' => 1);
        $tmparr['accountcode'] = array('value' => '', 'level' => 1);
        $tmparr['callgroup'] = array('value' => '', 'level' => 1);
        $tmparr['pickupgroup'] = array('value' => '', 'level' => 1);
        $tmparr['mailbox'] = array('value' => '', 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'dahdi', $tmparr);
        unset($tmparr);
        // iax2
        $tmparr = array();
        $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => 'isEmpty() && !confirm("' . $msgConfirmSecret . '")', 'failvalidationmsg' => $msgInvalidSecret);
        $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => '(isEmpty() && !confirm("' . $msgConfirmSecret . '")) || (!isEmpty() && weakSecret())', 'failvalidationmsg' => $msgInvalidSecret);
        $tmparr['notransfer'] = array('value' => 'yes', 'level' => 1);
        $tmparr['context'] = array('value' => 'from-internal', 'level' => 1);
        $tmparr['host'] = array('value' => 'dynamic', 'level' => 1);
        $tmparr['type'] = array('value' => 'friend', 'level' => 1);
        $tmparr['port'] = array('value' => '4569', 'level' => 1);
        $tmparr['qualify'] = array('value' => 'yes', 'level' => 1);
        $tmparr['disallow'] = array('value' => '', 'level' => 1);
        $tmparr['allow'] = array('value' => '', 'level' => 1);
        $tmparr['dial'] = array('value' => '', 'level' => 1);
        $tmparr['accountcode'] = array('value' => '', 'level' => 1);
        $tmparr['mailbox'] = array('value' => '', 'level' => 1);
        $tmparr['deny'] = array('value' => '0.0.0.0/0.0.0.0', 'level' => 1);
        $tmparr['permit'] = array('value' => '0.0.0.0/0.0.0.0', 'level' => 1);
        $tmparr['requirecalltoken'] = array('value' => '', 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'iax2', $tmparr);
        unset($tmparr);
        // sip
        $tmparr = array();
        $tmparr['secret'] = array('value' => '', 'level' => 0, 'jsvalidation' => '(isEmpty() && !confirm("' . $msgConfirmSecret . '")) || (!isEmpty() && weakSecret())', 'failvalidationmsg' => $msgInvalidSecret);
        $tmparr['dtmfmode'] = array('value' => 'rfc2833', 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidDTMFMODE);
        $tmparr['canreinvite'] = array('value' => 'no', 'level' => 1);
        $tmparr['context'] = array('value' => 'from-internal', 'level' => 1);
        $tmparr['host'] = array('value' => 'dynamic', 'level' => 1);
        $tmparr['type'] = array('value' => 'friend', 'level' => 1);
        $tmparr['nat'] = array('value' => 'yes', 'level' => 1);
        $tmparr['port'] = array('value' => '5060', 'level' => 1);
        $tmparr['qualify'] = array('value' => 'yes', 'level' => 1);
        $tmparr['callgroup'] = array('value' => '', 'level' => 1);
        $tmparr['pickupgroup'] = array('value' => '', 'level' => 1);
        $tmparr['disallow'] = array('value' => '', 'level' => 1);
        $tmparr['allow'] = array('value' => '', 'level' => 1);
        $tmparr['dial'] = array('value' => '', 'level' => 1);
        $tmparr['accountcode'] = array('value' => '', 'level' => 1);
        $tmparr['mailbox'] = array('value' => '', 'level' => 1);
        $tmparr['vmexten'] = array('value' => '', 'level' => 1);
        $tmparr['deny'] = array('value' => '0.0.0.0/0.0.0.0', 'level' => 1);
        $tmparr['permit'] = array('value' => '0.0.0.0/0.0.0.0', 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'sip', $tmparr);
        unset($tmparr);
        // custom
        $tmparr = array();
        $tmparr['dial'] = array('value' => '', 'level' => 0);
        $currentcomponent->addgeneralarrayitem('devtechs', 'custom', $tmparr);
        unset($tmparr);
        // Devices list
        if ($_SESSION["AMP_user"]->checkSection('999')) {
            $currentcomponent->addoptlistitem('devicelist', 'sip_generic', _("Generic SIP Device"));
            $currentcomponent->addoptlistitem('devicelist', 'iax2_generic', _("Generic IAX2 Device"));
            if (!ast_with_dahdi() || $amp_conf['ZAP2DAHDICOMPAT']) {
                $currentcomponent->addoptlistitem('devicelist', 'zap_generic', _("Generic ZAP Device"));
            }
            if (ast_with_dahdi()) {
                $currentcomponent->addoptlistitem('devicelist', 'dahdi_generic', _("Generic DAHDI Device"));
            }
            $currentcomponent->addoptlistitem('devicelist', 'custom_custom', _("Other (Custom) Device"));
        }
        if ($dispnum != 'devices') {
            $currentcomponent->addoptlistitem('devicelist', 'virtual', _("None (virtual exten)"));
        }
        $currentcomponent->setoptlistopts('devicelist', 'sort', false);
        // Option lists used by the gui
        $currentcomponent->addoptlistitem('devicetypelist', 'fixed', _("Fixed"));
        $currentcomponent->addoptlistitem('devicetypelist', 'adhoc', _("Adhoc"));
        $currentcomponent->setoptlistopts('devicetypelist', 'sort', false);
        $currentcomponent->addoptlistitem('deviceuserlist', 'none', _("none"));
        $currentcomponent->addoptlistitem('deviceuserlist', 'new', _("New User"));
        $users = core_users_list();
        if (isset($users)) {
            foreach ($users as $auser) {
                $currentcomponent->addoptlistitem('deviceuserlist', $auser[0], $auser[0]);
            }
        }
        $currentcomponent->setoptlistopts('deviceuserlist', 'sort', false);
        // Add the 'proces' functions
        $currentcomponent->addguifunc('core_devices_configpageload');
        $currentcomponent->addprocessfunc('core_devices_configprocess');
    }
}
function directory_draw_entries_all_users($id)
{
    $html = '';
    foreach (core_users_list() as $user) {
        $html .= directory_draw_entries_tr($id, $user[0], '', $user[1], 'vm', '', $id++, true);
    }
    return $html;
}
Esempio n. 10
0
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     // legacy but in case someone was using this we will leave it
     //
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if (DB::IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         foreach ($results2 as $keyword => $data) {
             if ($ver12) {
                 switch ($keyword) {
                     case 'ringinuse':
                     case 'autofill':
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             } else {
                 switch ($keyword) {
                     case trim($data) == '':
                     case 'monitor-join':
                         break;
                     case 'monitor-format':
                         if (strtolower($data) != 'no') {
                             $output .= "monitor-type=mixmonitor\n";
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'announce-position':
                         if ($ver16) {
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             }
         }
         // Now pull out all the memebers, one line for each
         //
         if ($amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = $users[$matches[1]];
                     str_replace(',', '\\,', $name);
                     $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = $users[$matches[1]];
                         str_replace(',', '\\,', $name);
                         $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _("Warning, there are compound recordings configured in one or more Queue configurations. Queues can not play these so they have been truncated to the first sound file. You should correct this problem.<br />Details:<br /><br />");
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
Esempio n. 11
0
function core_devices_configpageinit($dispnum)
{
    global $currentcomponent, $amp_conf;
    if ($dispnum == 'devices' || $dispnum == 'extensions') {
        // We don't call: $currentcomponent->addgeneralarray('devtechs') because the first
        // call to addgeneralarrayitem will initiate the array and this allows other modules
        // to add a new device type.
        // Some errors for the validation bits
        $msgInvalidChannel = _("Please enter the channel for this device");
        $msgConfirmSecret = _("You have not entered a Secret for this device, although this is possible it is generally bad practice to not assign a Secret to a device. Are you sure you want to leave the Secret empty?");
        $msgInvalidSecret = _("Please enter a Secret for this device");
        $secret_validation = '(isEmpty() && !confirm("' . $msgConfirmSecret . '"))';
        if ($amp_conf['DEVICE_STRONG_SECRETS']) {
            $secret_validation .= ' || (!isEmpty() && weakSecret())';
        }
        // zap
        $tmparr = array();
        $tt = _("The Zap channel number for this port.");
        $tmparr['channel'] = array('value' => '', 'tt' => $tt, 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel);
        $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing.");
        $tmparr['context'] = array('value' => 'from-internal', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Zap immediate mode setting, see Zap documentation for details.");
        $tmparr['immediate'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Zap signaling, usually fxo_ks when connected to an analog phone. Some special applications or channel bank connections may require fxs_ks or other valid settings. See Zap and card documentation for details.");
        $tmparr['signalling'] = array('value' => 'fxo_ks', 'tt' => $tt, 'level' => 1);
        $tt = _("Zap echocancel setting, see Zap documentation for details.");
        $tmparr['echocancel'] = array('value' => 'yes', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Whether to turn on echo cancellation when bridging between Zap channels. See Zap documentation for details.");
        $tmparr['echocancelwhenbridged'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Echo training requirements of this card. See Zap documentation for details.");
        $tmparr['echotraining'] = array('value' => '800', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Experimental and un-reliable setting to try and detect a busy signal. See Zap documentation for details.");
        $tmparr['busydetect'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Experimental and un-reliable setting to try and detect a busy signal, number of iterations to conclude busy. See Zap documentation for details.");
        $tmparr['busycount'] = array('value' => '7', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Experimental and un-reliable setting to try and detect call progress tones. See Zap documentation for details.");
        $tmparr['callprogress'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("How to dial this device, this should not be changed unless you know what you are doing.");
        $tmparr['dial'] = array('value' => '', 'tt' => $tt, 'level' => 2);
        $tt = _("Accountcode for this device.");
        $tmparr['accountcode'] = array('value' => '', 'tt' => $tt, 'level' => 1);
        $tt = _("Callgroup(s) that this device is part of, can be one or more callgroups, e.g. '1,3-5' would be in groups 1,3,4,5.");
        $tmparr['callgroup'] = array('value' => $amp_conf['DEVICE_CALLGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Pickupgroups(s) that this device can pickup calls from, can be one or more groups, e.g. '1,3-5' would be in groups 1,3,4,5. Device does not have to be in a group to be able to pickup calls from that group.");
        $tmparr['pickupgroup'] = array('value' => $amp_conf['DEVICE_PICKUPGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Mailbox for this device. This should not be changed unless you know what you are doing.");
        $tmparr['mailbox'] = array('value' => '', 'tt' => $tt, 'level' => 2);
        $currentcomponent->addgeneralarrayitem('devtechs', 'zap', $tmparr);
        unset($tmparr);
        // dahdi
        $tmparr = array();
        $tt = _("The DAHDi channel number for this port.");
        $tmparr['channel'] = array('value' => '', 'tt' => $tt, 'level' => 0, 'jsvalidation' => 'isEmpty()', 'failvalidationmsg' => $msgInvalidChannel);
        $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing.");
        $tmparr['context'] = array('value' => 'from-internal', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("DAHDi immediate mode setting, see DAHDi documentation for details.");
        $tmparr['immediate'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("DAHDi signalling, usually fxo_ks when connected to an analog phone. Some special applications or channel bank connections may require fxs_ks or other valid settings. See DAHDi and card documentation for details.");
        $tmparr['signalling'] = array('value' => 'fxo_ks', 'tt' => $tt, 'level' => 1);
        $tt = _("DAHDi echocancel setting, see DAHDi documentation for details.");
        $tmparr['echocancel'] = array('value' => 'yes', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Whether to turn on echo cancellation when bridging between DAHDi channels. See DAHDi documentation for details.");
        $tmparr['echocancelwhenbridged'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Echo training requirements of this card. See DAHDi documentation for details.");
        $tmparr['echotraining'] = array('value' => '800', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Experimental and un-reliable setting to try and detect a busy signal. See DAHDi documentation for details.");
        $tmparr['busydetect'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Experimental and un-reliable setting to try and detect a busy signal, number of iterations to conclude busy. See DAHDi documentation for details.");
        $tmparr['busycount'] = array('value' => '7', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $tt = _("Experimental and un-reliable setting to try and detect call progress tones. See DAHDi documentation for details.");
        $tmparr['callprogress'] = array('value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("How to dial this device, this should not be changed unless you know what you are doing.");
        $tmparr['dial'] = array('value' => '', 'level' => 2);
        $tt = _("Accountcode for this device.");
        $tmparr['accountcode'] = array('value' => '', 'tt' => $tt, 'level' => 1);
        $tt = _("Callgroup(s) that this device is part of, can be one or more callgroups, e.g. '1,3-5' would be in groups 1,3,4,5.");
        $tmparr['callgroup'] = array('value' => $amp_conf['DEVICE_CALLGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Pickupgroups(s) that this device can pickup calls from, can be one or more groups, e.g. '1,3-5' would be in groups 1,3,4,5. Device does not have to be in a group to be able to pickup calls from that group.");
        $tmparr['pickupgroup'] = array('value' => $amp_conf['DEVICE_PICKUPGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Mailbox for this device. This should not be changed unless you know what you are doing.");
        $tmparr['mailbox'] = array('value' => '', 'tt' => $tt, 'level' => 2);
        $currentcomponent->addgeneralarrayitem('devtechs', 'dahdi', $tmparr);
        unset($tmparr);
        // iax2
        $tmparr = array();
        $tt = _("Password (secret) configured for the device. Should be alphanumeric with at least 2 letters and numbers to keep secure.");
        $tmparr['secret'] = array('value' => '', 'tt' => $tt, 'level' => 0, 'jsvalidation' => $secret_validation, 'failvalidationmsg' => $msgInvalidSecret);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $select[] = array('value' => 'mediaonly', 'text' => _('Media Only'));
        $tt = _("IAX transfer capabilities, see the Asterisk documentation for details.");
        $tmparr['transfer'] = array('value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing.");
        $tmparr['context'] = array('value' => 'from-internal', 'tt' => $tt, 'level' => 1);
        $tt = _("Host settings for this device, almost always dynamic for endpoints.");
        $tmparr['host'] = array('value' => 'dynamic', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'friend', 'text' => 'friend');
        $select[] = array('value' => 'peer', 'text' => 'peer');
        $select[] = array('value' => 'user', 'text' => 'user');
        $tt = _("Asterisk connection type, usually friend for endpoints.");
        $tmparr['type'] = array('value' => 'friend', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Endpoint port number to use, usually 4569.");
        $tmparr['port'] = array('value' => '4569', 'tt' => $tt, 'level' => 1);
        $tt = _("Setting to yes (equivalent to 2000 msec) will send an OPTIONS packet to the endpoint periodically (default every minute). Used to monitor the health of the endpoint. If delays are longer then the qualify time, the endpoint will be taken offline and considered unreachable. Can be set to a value which is the msec threshold. Setting to no will turn this off. Can also be helpful to keep NAT pinholes open.");
        $tmparr['qualify'] = array('value' => $amp_conf['DEVICE_QUALIFY'], 'tt' => $tt, 'level' => 1);
        $tt = _("Disallowed codecs. Set this to all to remove all codecs defined in the general settings and then specify specific codecs separated by '&' on the 'allow' setting, or just disallow specific codecs separated by '&'.");
        $tmparr['disallow'] = array('value' => $amp_conf['DEVICE_DISALLOW'], 'tt' => $tt, 'level' => 1);
        $tt = _("Allow specific codecs, separated by the '&' sign and in priority order. E.g. 'ulaw&g729'. Codecs allowed in the general settings will also be allowed unless removed with the 'disallow' directive.");
        $tmparr['allow'] = array('value' => $amp_conf['DEVICE_ALLOW'], 'tt' => $tt, 'level' => 1);
        $tt = _("How to dial this device, this should not be changed unless you know what you are doing.");
        $tmparr['dial'] = array('value' => '', 'tt' => $tt, 'level' => 2);
        $tt = _("Accountcode for this device.");
        $tmparr['accountcode'] = array('value' => '', 'tt' => $tt, 'level' => 1);
        $tt = _("Mailbox for this device. This should not be changed unless you know what you are doing.");
        $tmparr['mailbox'] = array('value' => '', 'tt' => $tt, 'level' => 2);
        $tt = _("IP Address range to deny access to, in the form of network/netmask.");
        $tmparr['deny'] = array('value' => '0.0.0.0/0.0.0.0', 'tt' => $tt, 'level' => 1);
        $tt = _("IP Address range to allow access to, in the form of network/netmask. This can be a very useful security option when dealing with remote extensions that are at a known location (such as a branch office) or within a known ISP range for some home office situations.");
        $tmparr['permit'] = array('value' => '0.0.0.0/0.0.0.0', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'no', 'text' => _('No'));
        $select[] = array('value' => 'auto', 'text' => _('Auto'));
        $tt = _("IAX security setting. See IAX documentation and device compatibility for details.");
        $tmparr['requirecalltoken'] = array('value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'iax2', $tmparr);
        unset($tmparr);
        // sip
        unset($select);
        if (!empty($_REQUEST['tech_hardware'])) {
            $tmparr = explode('_', $_REQUEST['tech_hardware']);
            $deviceInfo['tech'] = $tmparr[0];
        } else {
            $tmparr = core_devices_get($_REQUEST['extdisplay']);
            $deviceInfo['tech'] = $tmparr['tech'];
        }
        unset($tmparr);
        $sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER');
        $tmparr['sipdriver'] = array('hidden' => true, 'value' => 'chan_' . strtolower($deviceInfo['tech']), 'level' => 0);
        //Inverted Driver, only allow the change if in certain modes
        if ($deviceInfo['tech'] == "sip") {
            $mydriver = "CHAN_SIP";
            $otherdriver = "CHAN_PJSIP";
        } else {
            $mydriver = "CHAN_PJSIP";
            $otherdriver = "CHAN_SIP";
        }
        $ttt = sprintf(_("Change To %s Driver"), $otherdriver);
        if ($sipdriver == 'both' || $sipdriver == 'chan_sip' && $deviceInfo['tech'] == 'pjsip' || $sipdriver == 'chan_pjsip' && $deviceInfo['tech'] == 'sip') {
            $tt = _("Change the SIP Channel Driver to use {$otherdriver}.");
            $tmparr['changecdriver'] = array('text' => $ttt, 'prompttext' => 'Change SIP Driver', 'type' => 'button', 'value' => 'button', 'tt' => $tt, 'level' => 1, 'jsvalidation' => "frm_" . $dispnum . "_changeDriver();return false;");
        } else {
            $tt = _("You cannot change to {$otherdriver} as it is not enabled. Please enable {$otherdriver} in Advanced Settings");
            $tmparr['changecdriver'] = array('text' => _("Changing SIP Driver unavailable"), 'prompttext' => $ttt, 'type' => 'button', 'value' => 'button', 'tt' => $tt, 'level' => 1, 'disable' => true);
        }
        $tt = _("Password (secret) configured for the device. Should be alphanumeric with at least 2 letters and numbers to keep secure.") . ' [secret]';
        $tmparr['secret'] = array('prompttext' => 'Secret', 'value' => '', 'tt' => $tt, 'level' => 0, 'jsvalidation' => $secret_validation, 'failvalidationmsg' => $msgInvalidSecret);
        if ($mydriver == "CHAN_PJSIP") {
            $select[] = array('value' => 'rfc4733', 'text' => _('RFC 4733'));
        } else {
            $select[] = array('value' => 'rfc2833', 'text' => _('RFC 2833'));
            $select[] = array('value' => 'auto', 'text' => _('Auto'));
            $select[] = array('value' => 'shortinfo', 'text' => _('SIP INFO (application/dtmf)'));
        }
        unset($tt, $ttt, $mydriver, $otherdriver);
        $select[] = array('value' => 'info', 'text' => _('SIP INFO (application/dtmf-relay)'));
        $select[] = array('value' => 'inband', 'text' => _('In band audio (Not recommended)'));
        $tt = _("The DTMF signaling mode used by this device, usually RFC for most phones.") . ' [dtmfmode]';
        $tmparr['dtmfmode'] = array('prompttext' => _('DTMF Signaling'), 'value' => 'rfc2833', 'tt' => $tt, 'select' => $select, 'level' => 0);
        // $amp_conf['DEVICE_SIP_CANREINVITE']
        // $amp_conf['DEVICE_SIP_TRUSTRPID']
        // $amp_conf['DEVICE_SIP_SENDRPID']
        // $amp_conf['DEVICE_SIP_NAT']
        // $amp_conf['DEVICE_SIP_ENCRYPTION']
        // $amp_conf['DEVICE_SIP_QUALIFYFREQ']
        // $amp_conf['DEVICE_QUALIFY']
        // $amp_conf['DEVICE_DISALLOW']
        // $amp_conf['DEVICE_ALLOW']
        // $amp_conf['DEVICE_CALLGROUP']
        // $amp_conf['DEVICE_PICKUPGROUP']
        unset($select);
        $tt = _("Re-Invite policy for this device, see Asterisk documentation for details.") . ' [canreinvite]';
        $select[] = array('value' => 'no', 'text' => _('No'));
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $select[] = array('value' => 'nonat', 'text' => 'nonat');
        $select[] = array('value' => 'update', 'text' => 'update');
        $tmparr['canreinvite'] = array('prompttext' => _('Can Reinvite'), 'value' => $amp_conf['DEVICE_SIP_CANREINVITE'], 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Asterisk context this device will send calls to. Only change this is you know what you are doing.") . ' [context]';
        $tmparr['context'] = array('prompttext' => _('Context'), 'value' => 'from-internal', 'tt' => $tt, 'level' => 1);
        $tt = _("Host settings for this device, almost always dynamic for endpoints.") . ' [host]';
        $tmparr['host'] = array('prompttext' => _('Host'), 'value' => 'dynamic', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'no', 'text' => _('No'));
        $select[] = array('value' => 'yes', 'text' => _('Yes'));
        $tt = _("Whether Asterisk should trust the RPID settings from this device. Usually should be yes for CONNECTEDLINE() functionality to work if supported by the endpoint.") . '[trustrpid]';
        $tmparr['trustrpid'] = array('prompttext' => _('Trust RPID'), 'value' => $amp_conf['DEVICE_SIP_TRUSTRPID'], 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'no', 'text' => _('None'));
        $select[] = array('value' => 'sdes', 'text' => _('SRTP via in-SDP'));
        $select[] = array('value' => 'dtls', 'text' => _('DTLS-SRTP'));
        $tt = _("Media (RTP) Encryption. Normally you would use None, unless you have explicitly set up SDP or DTLS.") . ' [media-encryption]';
        $tmparr['mediaencryption'] = array('prompttext' => _('Media Encryption'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'no', 'text' => _('No'));
        $select[] = array('value' => 'yes', 'text' => _('Send Remote-Party-ID header'));
        if (version_compare($amp_conf['ASTVERSION'], '1.8', 'ge')) {
            $select[] = array('value' => 'pai', 'text' => _('Send P-Asserted-Identity header'));
        }
        $tt = _("Whether Asterisk should send RPID (or PAI) info to the device. Usually should be enabled to the settings used by your device for CONNECTEDLINE() functionality to work if supported by the endpoint.") . '[sendrpid]';
        $tmparr['sendrpid'] = array('prompttext' => _('Send RPID'), 'value' => $amp_conf['DEVICE_SIP_SENDRPID'], 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'friend', 'text' => 'friend');
        $select[] = array('value' => 'peer', 'text' => 'peer');
        $select[] = array('value' => 'user', 'text' => 'user');
        $tt = _("Asterisk connection type, usually friend for endpoints.") . '[type]';
        $tmparr['type'] = array('prompttext' => _('Connection Type'), 'value' => 'friend', 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => _('Yes - (force_rport,comedia)'));
        $select[] = array('value' => 'no', 'text' => _('No - (no)'));
        if (version_compare($amp_conf['ASTVERSION'], '1.8', 'ge')) {
            $select[] = array('value' => 'force_rport', 'text' => _('Force rport - (force_rport)'));
            $select[] = array('value' => 'comedia', 'text' => _('comedia - (comedia)'));
        }
        if (version_compare($amp_conf['ASTVERSION'], '11.5', 'ge')) {
            $select[] = array('value' => 'auto_force_rport,auto_comedia', 'text' => _('Automatic Force Both - (auto_force_rport,auto_comedia)'));
            $select[] = array('value' => 'auto_force_rport', 'text' => _('Automatic Force rport - (auto_force_rport)'));
            $select[] = array('value' => 'auto_comedia', 'text' => _('Automatic comedia - (auto_comedia)'));
        }
        $select[] = array('value' => 'never', 'text' => _('never - (no)'));
        $select[] = array('value' => 'route', 'text' => _('route - (force_rport)'));
        $tt = _("NAT setting, see Asterisk documentation for details. Yes usually works for both internal and external devices. Set to No if the device will always be internal.") . '[nat]';
        $tmparr['nat'] = array('prompttext' => _('NAT Mode'), 'value' => $amp_conf['DEVICE_SIP_NAT'], 'tt' => $tt, 'select' => $select, 'level' => 0);
        $tt = _("Endpoint port number to use, usually 5060. Some 2 ports devices such as ATA may used 5061 for the second port.");
        $tmparr['port'] = array('prompttext' => _('Port'), 'value' => '5060', 'tt' => $tt, 'level' => 1);
        $tt = _("Setting to yes (equivalent to 2000 msec) will send an OPTIONS packet to the endpoint periodically (default every minute). Used to monitor the health of the endpoint. If delays are longer then the qualify time, the endpoint will be taken offline and considered unreachable. Can be set to a value which is the msec threshhold. Setting to no will turn this off. Can also be helpful to keep NAT pinholes open.");
        $tmparr['qualify'] = array('prompttext' => _('Qualify'), 'value' => $amp_conf['DEVICE_QUALIFY'], 'tt' => $tt, 'level' => 1);
        if (version_compare($amp_conf['ASTVERSION'], '1.6', 'ge')) {
            $tt = _("Frequency in seconds to send qualify messages to the endpoint.");
            $tmparr['qualifyfreq'] = array('prompttext' => _('Qualify Frequency'), 'value' => $amp_conf['DEVICE_SIP_QUALIFYFREQ'], 'tt' => $tt, 'level' => 1);
        }
        if (version_compare($amp_conf['ASTVERSION'], '1.8', 'ge')) {
            unset($select);
            $select[] = array('value' => 'udp,tcp,tls', 'text' => _('All - UDP Primary'));
            $select[] = array('value' => 'tcp,udp,tls', 'text' => _('All - TCP Primary'));
            $select[] = array('value' => 'tls,udp,tcp', 'text' => _('All - TLS Primary'));
            if (version_compare($amp_conf['ASTVERSION'], '11', 'ge')) {
                $select[] = array('value' => 'ws,udp,tcp,tls', 'text' => _('All - WS Primary'));
            }
            $select[] = array('value' => 'udp', 'text' => _('UDP Only'));
            $select[] = array('value' => 'tcp', 'text' => _('TCP Only'));
            $select[] = array('value' => 'tls', 'text' => _('TLS Only'));
            if (version_compare($amp_conf['ASTVERSION'], '11', 'ge')) {
                $select[] = array('value' => 'ws', 'text' => _('WS Only'));
            }
            $tt = _("This sets the allowed transport settings for this device and the default (Primary) transport for outgoing. The default transport is only used for outbound messages until a registration takes place.  During the peer registration the transport type may change to another supported type if the peer requests so. In most common cases, this does not have to be changed as most devices register in conjunction with the host=dynamic setting. If you are using TCP and/or TLS you need to make sure the general SIP Settings are configured for the system to operate in those modes and for TLS, proper certificates have been generated and configured. If you are using websockets (such as WebRTC) then you must select an option that includes WS");
            $tmparr['transport'] = array('prompttext' => _('Transport'), 'value' => 'Auto', 'tt' => $tt, 'select' => $select, 'level' => 1);
            if (version_compare($amp_conf['ASTVERSION'], '11', 'ge')) {
                unset($select);
                $select[] = array('value' => 'no', 'text' => _('No'));
                $select[] = array('value' => 'yes', 'text' => _('Yes'));
                $tt = _("Whether to Enable AVPF. Defaults to no. The WebRTC standard has selected AVPF as the audio video profile to use for media streams. This is not the default profile in use by Asterisk. As a result the following must be enabled to use WebRTC");
                $tmparr['avpf'] = array('prompttext' => _('Enable AVPF'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
            }
            if (version_compare($amp_conf['ASTVERSION'], '11', 'ge')) {
                unset($select);
                $select[] = array('value' => 'no', 'text' => _('No'));
                $select[] = array('value' => 'yes', 'text' => _('Yes'));
                $tt = _("Force 'RTP/AVP', 'RTP/AVPF', 'RTP/SAVP', and 'RTP/SAVPF' to be used for media streams when appropriate, even if a DTLS stream is present.");
                $tmparr['force_avp'] = array('prompttext' => _('Force AVP'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
            }
            if (version_compare($amp_conf['ASTVERSION'], '11', 'ge')) {
                unset($select);
                $select[] = array('value' => 'no', 'text' => _('No'));
                $select[] = array('value' => 'yes', 'text' => _('Yes'));
                $tt = _("Whether to Enable ICE Support. Defaults to no. ICE (Interactive Connectivity Establishment) is a protocol for Network Address Translator(NAT) traversal for UDP-based multimedia sessions established with the offer/answer model. This option is commonly enabled in WebRTC setups");
                $tmparr['icesupport'] = array('prompttext' => _('Enable ICE Support'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
            }
            unset($select);
            $select[] = array('value' => 'no', 'text' => _('No'));
            $select[] = array('value' => 'yes', 'text' => _('Yes (SRTP only)'));
            $tt = _("Whether to offer SRTP encrypted media (and only SRTP encrypted media) on outgoing calls to a peer. Calls will fail with HANGUPCAUSE=58 if the peer does not support SRTP. Defaults to no.");
            $tmparr['encryption'] = array('prompttext' => _('Enable Encryption'), 'value' => $amp_conf['DEVICE_SIP_ENCRYPTION'], 'tt' => $tt, 'select' => $select, 'level' => 1);
        }
        $tt = _("Callgroup(s) that this device is part of, can be one or more callgroups, e.g. '1,3-5' would be in groups 1,3,4,5.");
        $tmparr['callgroup'] = array('prompttext' => _('Call Groups'), 'value' => $amp_conf['DEVICE_CALLGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Pickupgroups(s) that this device can pickup calls from, can be one or more groups, e.g. '1,3-5' would be in groups 1,3,4,5. Device does not have to be in a group to be able to pickup calls from that group.");
        $tmparr['pickupgroup'] = array('prompttext' => _('Pickup Groups'), 'value' => $amp_conf['DEVICE_PICKUPGROUP'], 'tt' => $tt, 'level' => 1);
        $tt = _("Disallowed codecs. Set this to all to remove all codecs defined in the general settings and then specify specific codecs separated by '&' on the 'allow' setting, or just disallow specific codecs separated by '&'.");
        $tmparr['disallow'] = array('prompttext' => _('Disallowed Codecs'), 'value' => $amp_conf['DEVICE_DISALLOW'], 'tt' => $tt, 'level' => 1);
        $tt = _("Allow specific codecs, separated by the '&' sign and in priority order. E.g. 'ulaw&g729'. Codecs allowed in the general settings will also be allowed unless removed with the 'disallow' directive.");
        $tmparr['allow'] = array('prompttext' => _('Allowed Codecs'), 'value' => $amp_conf['DEVICE_ALLOW'], 'tt' => $tt, 'level' => 1);
        $tt = _("How to dial this device, this should not be changed unless you know what you are doing.");
        $tmparr['dial'] = array('prompttext' => _('Dial'), 'value' => '', 'tt' => $tt, 'level' => 2);
        $tt = _("Accountcode for this device.");
        $tmparr['accountcode'] = array('prompttext' => _('Account Code'), 'value' => '', 'tt' => $tt, 'level' => 1);
        $tt = _("Mailbox for this device. This should not be changed unless you know what you are doing.");
        $tmparr['mailbox'] = array('prompttext' => _('Mailbox'), 'value' => '', 'tt' => $tt, 'level' => 2);
        $tt = _("Asterisk dialplan extension to reach voicemail for this device. Some devices use this to auto-program the voicemail button on the endpoint. If left blank, the default vmexten setting is automatically configured by the voicemail module. Only change this on devices that may have special needs.");
        $tmparr['vmexten'] = array('prompttext' => _('Voicemail Extension'), 'value' => '', 'tt' => $tt, 'level' => 1);
        $tt = _("IP Address range to deny access to, in the form of network/netmask.");
        $tmparr['deny'] = array('prompttext' => _('Deny'), 'value' => '0.0.0.0/0.0.0.0', 'tt' => $tt, 'level' => 1);
        $tt = _("IP Address range to allow access to, in the form of network/netmask. This can be a very useful security option when dealing with remote extensions that are at a known location (such as a branch office) or within a known ISP range for some home office situations.");
        $tmparr['permit'] = array('prompttext' => _('Permit'), 'value' => '0.0.0.0/0.0.0.0', 'tt' => $tt, 'level' => 1);
        $currentcomponent->addgeneralarrayitem('devtechs', 'sip', $tmparr);
        //pjsip shares common functionality with chan_sip so unset all of those which dont make sense to pjsip
        unset($tmparr['force_avp'], $tmparr['permit'], $tmparr['deny'], $tmparr['accountcode'], $tmparr['encryption'], $tmparr['type'], $tmparr['qualify'], $tmparr['port'], $tmparr['canreinvite'], $tmparr['host'], $tmparr['nat']);
        $tt = _("Maximum number of Endpoints that can associate with this Device");
        $tmparr['max_contacts'] = array('prompttext' => _('Max Contacts'), 'value' => '1', 'tt' => $tt, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'yes', 'text' => 'Yes');
        $select[] = array('value' => 'no', 'text' => 'No');
        if (version_compare($amp_conf['ASTVERSION'], '12.4.0', 'ge')) {
            //media_use_received_transport
            $tt = _("Determines whether res_pjsip will use the media transport received in the offer SDP in the corresponding answer SDP.");
            $tmparr['media_use_received_transport'] = array('prompttext' => _('Media Use Received Transport'), 'value' => 'no', 'tt' => $tt, 'select' => $select, 'level' => 1);
        }
        $tt = _("Enforce that RTP must be symmetric. If this device is natting in it is usually a good idea to enable this. Disable only if you are having issues.");
        $tmparr['rtp_symmetric'] = array('prompttext' => _('RTP Symmetric'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1);
        $tt = _("Allow Contact header to be rewritten with the source IP address-port");
        $tmparr['rewrite_contact'] = array('prompttext' => _('Rewrite Contact'), 'value' => 'yes', 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        $select[] = array('value' => 'solicited', 'text' => 'Solicited');
        $select[] = array('value' => 'unsolicited', 'text' => 'Unsolicited');
        $tt = _("For Message Waiting indicators there are two types: Solicited and Unsolicited. Solicited means Subscribe 200 then Notify 200. Unsolicited means only Notify 200. No need to Subscribe. Solicited is the default and should only be changed if you see errors in the Asterisk logs");
        $tmparr['mwi_subscription'] = array('prompttext' => _('MWI Subscription Type'), 'value' => 'solicited', 'tt' => $tt, 'select' => $select, 'level' => 1);
        unset($select);
        //Use the transport engine, don't cross migrate anymore, it just doesn't work
        $transports = FreePBX::create()->PJSip->getActiveTransports();
        foreach ($transports as $transport) {
            $select[] = array('value' => $transport['value'], 'text' => $transport['text']);
        }
        $tmparr['transport']['select'] = $select;
        $tmparr['transport']['level'] = 0;
        unset($select);
        $currentcomponent->addgeneralarrayitem('devtechs', 'pjsip', $tmparr);
        unset($tmparr);
        $currentcomponent->addjsfunc('changeDriver()', "\n\t\tif(confirm('" . _('Are you Sure you want to Change the SIP Channel Driver? (The Page will Refresh, then you MUST hit save when you are done to propagate the new settings)') . "')) {\n\t\t\tif(\$('#devinfo_sipdriver').val() == 'chan_sip') {\n\t\t\t\t\$('#devinfo_sipdriver').val('chan_pjsip');\n\t\t\t} else {\n\t\t\t\t\$('#devinfo_sipdriver').val('chan_sip');\n\t\t\t}\n\t\t\t\$('form[name=frm_" . $dispnum . "]').append('<input type=\"hidden\" name=\"changesipdriver\" value=\"yes\">');\n\t\t\t\$('form[name=frm_" . $dispnum . "]').submit();\n\t\t}\n\t\t", 0);
        // custom
        $tmparr = array();
        $tt = _("How to dial this device. This will be device specific. For example, a custom device which is really a remote SIP URI might be configured such as SIP/joe@somedomain.com");
        $tmparr['dial'] = array('value' => '', 'tt' => $tt, 'level' => 0);
        $currentcomponent->addgeneralarrayitem('devtechs', 'custom', $tmparr);
        unset($tmparr);
        // Devices list
        if ($_SESSION["AMP_user"]->checkSection('999')) {
            $sipdriver = FreePBX::create()->Config->get_conf_setting('ASTSIPDRIVER');
            if ($sipdriver == 'both') {
                $currentcomponent->addoptlistitem('devicelist', 'pjsip_generic', _("Generic PJSIP Device"));
                $currentcomponent->addoptlistitem('devicelist', 'sip_generic', _("Generic CHAN SIP Device"));
            } elseif ($sipdriver == 'chan_sip') {
                $currentcomponent->addoptlistitem('devicelist', 'sip_generic', _("Generic CHAN SIP Device"));
            } elseif ($sipdriver == 'chan_pjsip') {
                $currentcomponent->addoptlistitem('devicelist', 'pjsip_generic', _("Generic PJSIP Device"));
            }
            $currentcomponent->addoptlistitem('devicelist', 'iax2_generic', _("Generic IAX2 Device"));
            $currentcomponent->addoptlistitem('devicelist', 'dahdi_generic', _("Generic DAHDi Device"));
            $currentcomponent->addoptlistitem('devicelist', 'custom_custom', _("Other (Custom) Device"));
        }
        if ($dispnum != 'devices') {
            $currentcomponent->addoptlistitem('devicelist', 'virtual', _("None (virtual exten)"));
        }
        $currentcomponent->setoptlistopts('devicelist', 'sort', false);
        // Option lists used by the gui
        $currentcomponent->addoptlistitem('devicetypelist', 'fixed', _("Fixed"));
        $currentcomponent->addoptlistitem('devicetypelist', 'adhoc', _("Adhoc"));
        $currentcomponent->setoptlistopts('devicetypelist', 'sort', false);
        $currentcomponent->addoptlistitem('deviceuserlist', 'none', _("none"));
        $currentcomponent->addoptlistitem('deviceuserlist', 'new', _("New User"));
        $users = core_users_list();
        if (isset($users)) {
            foreach ($users as $auser) {
                $currentcomponent->addoptlistitem('deviceuserlist', $auser[0], $auser[0] . " (" . $auser[1] . ")");
            }
        }
        $currentcomponent->setoptlistopts('deviceuserlist', 'sort', false);
        // Add the 'proces' functions
        $currentcomponent->addguifunc('core_devices_configpageload');
        $currentcomponent->addprocessfunc('core_devices_configprocess');
    }
}
Esempio n. 12
0
function show_aststats()
{
    global $amp_conf;
    global $astinfo;
    global $db;
    $out = '';
    $channels = $astinfo->get_channel_totals();
    // figure out max_calls
    // guess at the max calls: number of users
    if (!isset($_SESSION["calculated_max_calls"])) {
        // set max calls to either MAXCALLS in amportal.conf, or the number of users in the system
        if (isset($amp_conf['MAXCALLS'])) {
            $_SESSION["calculated_max_calls"] = $amp_conf["MAXCALLS"];
        } else {
            if (function_exists('core_users_list')) {
                $_SESSION["calculated_max_calls"] = count(core_users_list());
            } else {
                $_SESSION["calculated_max_calls"] = 1;
            }
        }
    }
    // we currently see more calls than we guessed, increase it
    if ($channels['total_calls'] > $_SESSION["calculated_max_calls"]) {
        $_SESSION["calculated_max_calls"] = $channels['total_calls'];
    }
    $max_calls = $_SESSION["calculated_max_calls"];
    $classes = array(0 => 'graphok');
    $max_chans = $max_calls * 2;
    $out .= "<h3>" . _("FreePBX Statistics") . "</h3>";
    $out .= draw_graph(_('Total active calls'), '', $channels['total_calls'], $max_calls, $classes, false, BAR_WIDTH_LEFT);
    $out .= draw_graph(_('Internal calls'), '', $channels['internal_calls'], $max_calls, $classes, false, BAR_WIDTH_LEFT);
    $out .= draw_graph(_('External calls'), '', $channels['external_calls'], $max_calls, $classes, false, BAR_WIDTH_LEFT);
    $out .= draw_graph(_('Total active channels'), '', $channels['total_channels'], $max_chans, $classes, false, BAR_WIDTH_LEFT);
    $out .= "<h4>" . _("FreePBX Connections") . "</h4>";
    /* This is generally very bad style, and we should look at adding this to core_devices_list or another core
     * function. However, since this is in Ajax lite weight code, it is currently the cleanest way to get the sip and iax2
     * devices in a hash format that we would like to pass to the class
     */
    $sql = "SELECT `id` FROM `devices` WHERE `tech` IN ('sip', 'iax2')";
    $devices = $db->getCol($sql);
    if (DB::IsError($devices)) {
        $devices = false;
    } else {
        $devices = array_flip($devices);
    }
    $conns = $astinfo->get_connections($devices);
    if ($conns['users_total'] > 0) {
        $out .= draw_graph(_('IP Phones Online'), '', $conns['users_online'], $conns['users_total'], $classes, false, BAR_WIDTH_LEFT);
    }
    if ($conns['trunks_total'] > 0) {
        $out .= draw_graph(_('IP Trunks Online'), '', $conns['trunks_online'], $conns['trunks_total'], $classes, false, BAR_WIDTH_LEFT);
    }
    if ($conns['registrations_total'] > 0) {
        $out .= draw_graph(_('IP Trunk Registrations'), '', $conns['registrations_online'], $conns['registrations_total'], $classes, false, BAR_WIDTH_LEFT);
    }
    return $out;
}
Esempio n. 13
0
function campon_toggle($c)
{
    global $ext;
    global $amp_conf;
    if (!$amp_conf['CC_ENABLE']) {
        return true;
    }
    $id = "app-campon-toggle";
    // The context to be included
    $hint_context = 'ext-local';
    $ext->addInclude('from-internal-additional', $id);
    // Add the include from from-internal
    $ext->add($id, $c, '', new ext_answer(''));
    $ext->add($id, $c, '', new ext_set('CCSS_SETUP', 'TRUE'));
    // keep from calling normal sub-ccss
    $ext->add($id, $c, '', new ext_macro('user-callerid'));
    $ext->add($id, $c, '', new ext_execif('$["${EXTENSION_STATE(' . $c . '${AMPUSER}@' . $hint_context . ')}" = "INUSE"]', 'CallCompletionCancel', '', 'CallCompletionRequest', ''));
    $ext->add($id, $c, '', new ext_noop_trace('CC_REQUEST_RESULT: ${CC_REQUEST_RESULT} CC_REQUEST_REASON: ${CC_REQUEST_REASON} LastNumber: ${DB(AMPUSER/${AMPUSER}/ccss/last_number)}'));
    $ext->add($id, $c, '', new ext_noop_trace('CC_CANCEL_RESULT: ${CC_CANCEL_RESULT} CC_CANCEL_REASON: ${CC_CANCEL_REASON}'));
    $ext->add($id, $c, '', new ext_playback('beep'));
    $ext->add($id, $c, '', new ext_macro('hangupcall'));
    $ext->addGlobal('CAMPONTOGGLE', $c);
    $userlist = core_users_list();
    if (is_array($userlist)) {
        foreach ($userlist as $item) {
            $hint_code = $c . $item[0];
            $ext->add($hint_context, $hint_code, '', new ext_goto('1', $c, $id));
            if (!$amp_conf['DYNAMICHINTS']) {
                $devices = core_hint_get($item[0]);
                $dev_arr = explode('&', $devices);
                $hint_val = 'ccss:' . implode('&ccss:', $dev_arr);
                $ext->addHint($hint_context, $hint_code, $hint_val);
            }
        }
    }
}
Esempio n. 14
0
function findmefollow_draw_general($fmfm, &$currentcomponent, $category, $fmfmdisabled, $recordingslist, $moh)
{
    global $display;
    $js = "\n\tif(\$('#extension').val().trim().length === 0) {\n\t\t\$('#fmfm_ddial1').prop('checked', true);\n\t\twarnInvalid(\$('#extension'),'" . sprintf(_("Please enter a valid %s number"), $display == "extensions" ? _("extension") : _("device")) . "');\n\t\treturn false;\n\t}\n\tvar curval = \$('#fmfm_grplist').val();\n\tif(curval.trim().length === 0){\n\t\t\$('#fmfm_grplist').val(\$('#extension').val()+'\\n');\n\t}\n\treturn true;\n\t";
    $currentcomponent->addjsfunc('fmfmEnabled(notused)', $js);
    $js = "\n\t\tvar ext = \$('#fmfm_quickpick').val(),\n\t\t\t\tfml = \$('#fmfm_grplist').val().trim()\n\t\tif(fml.length > 0) {\n\t\t\t\$('#fmfm_grplist').val(fml + '\\n' + ext).trigger('autosize.resize');;\n\t\t} else {\n\t\t\t\$('#fmfm_grplist').val(ext).trigger('autosize.resize');;\n\t\t}\n\t";
    $currentcomponent->addjsfunc('fmfmQuickPick(notused)', $js);
    $section = _("General Settings");
    $guidefaults = array("elemname" => "", "prompttext" => "", "helptext" => "", "currentvalue" => "", "valarray" => array(), "jsonclick" => '', "jsvalidation" => "", "failvalidationmsg" => "", "canbeempty" => true, "maxchars" => 0, "disable" => false, "inputgroup" => false, "class" => "", "cblabel" => 'Enable', "disabled_value" => 'DEFAULT', "check_enables" => 'true', "cbdisable" => false, "cbclass" => '');
    $el = array("elemname" => "fmfm_ddial", "prompttext" => _('Enabled'), "helptext" => _('By default (Yes) any call to this extension will go to this Follow-Me instead, including directory calls by name from IVRs. If set to "No", calls will go only to the extension. Destinations that directly specify FollowMe will come here regardless. Setting this to "No" is often used in conjunction with VmX Locater, where you want a call to ring the extension, and then only if the caller chooses to find you do you want the call to go through FollowMe.'), "currentvalue" => $fmfmdisabled ? 'disabled' : 'enabled', "valarray" => array(array("value" => "enabled", "text" => _("Yes")), array("value" => "disabled", "text" => _("No"))), "jsonclick" => "frm_{$display}_fmfmEnabled() && frm_{$display}_fmfmConfirmEnabled() && frm_{$display}_fmfmCIDMode()", "class" => "", "disable" => "", "pairedvalues" => false);
    $currentcomponent->addguielem($section, new gui_radio(array_merge($guidefaults, $el)), $category);
    $sixtey = array();
    for ($i = 0; $i <= 60; $i++) {
        $sixtey[] = array("value" => $i, "text" => $i);
    }
    $el = array("elemname" => "fmfm_pre_ring", "prompttext" => _('Initial Ring Time'), "helptext" => _("This is the number of seconds to ring the primary extension prior to proceeding to the follow-me list. The extension can also be included in the follow-me list. A 0 setting will bypass this."), "currentvalue" => $fmfm['pre_ring'], "valarray" => $sixtey, "class" => "fpbx-fmfm", "canbeempty" => false, "jsvalidation" => "frm_{$display}_fmfmCheckFixed()");
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $helptext = '<b>' . _("ringallv2") . '</b>: ' . _("ring Extension for duration set in Initial Ring Time, and then, while continuing call to extension, ring Follow-Me List for duration set in Ring Time.") . '<br>' . '<b>' . _("ringall") . '</b>:  ' . _("ring Extension for duration set in Initial Ring Time, and then terminate call to Extension and ring Follow-Me List for duration set in Ring Time.") . '<br>' . '<b>' . _("hunt") . '</b>: ' . _("take turns ringing each available extension") . '<br>' . '<b>' . _("memoryhunt") . '</b>: ' . _("ring first extension in the list, then ring the 1st and 2nd extension, then ring 1st 2nd and 3rd extension in the list.... etc.") . '<br>' . '<b>' . _("*-prim") . '</b>:  ' . _("these modes act as described above. However, if the primary extension (first in list) is occupied, the other extensions will not be rung. If the primary is FreePBX DND, it won't be rung. If the primary is FreePBX CF unconditional, then all will be rung") . '<br>' . '<b>' . _("firstavailable") . '</b>:  ' . _("ring only the first available channel") . '<br>' . '<b>' . _("firstnotonphone") . '</b>:  ' . _("ring only the first channel which is not off hook - ignore CW") . '';
    $items = array('ringallv2', 'ringallv2-prim', 'ringall', 'ringall-prim', 'hunt', 'hunt-prim', 'memoryhunt', 'memoryhunt-prim', 'firstavailable', 'firstnotonphone');
    $optlist = array();
    foreach ($items as $item) {
        $optlist[] = array("value" => $item, "text" => $item);
    }
    $el = array("elemname" => "fmfm_strategy", "prompttext" => _("Ring Strategy"), "helptext" => $helptext, "currentvalue" => $fmfm['strategy'], "valarray" => $optlist, "class" => "fpbx-fmfm", "canbeempty" => false);
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $el = array("elemname" => "fmfm_grptime", "prompttext" => _('Ring Time'), "helptext" => _("Time in seconds that the phones will ring. For all hunt style ring strategies, this is the time for each iteration of phone(s) that are rung"), "currentvalue" => $fmfm['grptime'], "valarray" => $sixtey, "class" => "fpbx-fmfm", "canbeempty" => false);
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $el = array("elemname" => "fmfm_grplist", "prompttext" => _('Follow-Me List'), "helptext" => _("List extensions to ring, one per line, or use the Extension Quick Pick below.<br><br>You can include an extension on a remote system, or an external number by suffixing a number with a pound (#).  ex:  2448089# would dial 2448089 on the appropriate trunk (see Outbound Routing)."), "currentvalue" => str_replace("-", "\n", $fmfm['grplist']), "canbeempty" => false, "class" => "fpbx-fmfm", "jsvalidation" => "frm_{$display}_fmfmListEmpty()", "failvalidationmsg" => _('Follow-Me List can not be empty if Follow-Me is enabled'));
    $currentcomponent->addguielem($section, new gui_textarea(array_merge($guidefaults, $el)), $category);
    $optlist = array();
    $optlist[] = array("value" => "", "text" => _("(pick extension)"));
    foreach (core_users_list() as $result) {
        $optlist[] = array("value" => $result[0], "text" => $result[0] . " (" . $result[1] . ")");
    }
    $el = array("elemname" => "fmfm_quickpick", "prompttext" => _('Extension Quick Pick'), "helptext" => _("Choose an extension to append to the end of the extension list above."), "currentvalue" => "", "valarray" => $optlist, "class" => "fpbx-fmfm", "canbeempty" => false, "onchange" => "frm_{$display}_fmfmQuickPick()");
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $el = array("elemname" => "fmfm_annmsg_id", "prompttext" => _('Announcement'), "helptext" => _("Message to be played to the caller before dialing this group.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left"), "currentvalue" => $fmfm['annmsg_id'], "valarray" => $recordingslist, "class" => "fpbx-fmfm", "canbeempty" => false);
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $optlist = array();
    $optlist[] = array("value" => "Ring", "text" => _("Ring"));
    if (!empty($moh)) {
        foreach ($moh as $music) {
            $optlist[] = array("value" => $music, "text" => $music);
        }
    }
    $el = array("elemname" => "fmfm_ringing", "prompttext" => _('Play Music On Hold'), "helptext" => _("If you select a Music on Hold class to play, instead of 'Ring', they will hear that instead of Ringing while they are waiting for someone to pick up."), "currentvalue" => $fmfm['ringing'], "valarray" => $optlist, "class" => "fpbx-fmfm", "canbeempty" => false);
    $currentcomponent->addguielem($section, new gui_selectbox(array_merge($guidefaults, $el)), $category);
    $el = array("elemname" => "fmfm_grppre", "prompttext" => _('CID Name Prefix'), "helptext" => _('You can optionally prefix the Caller ID name when ringing extensions in this group. ie: If you prefix with "Sales:", a call from John Doe would display as "Sales:John Doe" on the extensions that ring.'), "currentvalue" => $fmfm['grppre'], "canbeempty" => true, "class" => "fpbx-fmfm");
    $currentcomponent->addguielem($section, new gui_textbox(array_merge($guidefaults, $el)), $category);
    $el = array("elemname" => "fmfm_dring", "prompttext" => _('Alert Info'), "helptext" => _('You can optionally include an Alert Info which can create distinctive rings on SIP phones.'), "currentvalue" => $fmfm['dring'], "canbeempty" => true, "class" => "fpbx-fmfm");
    $currentcomponent->addguielem($section, new gui_alertinfodrawselects(array_merge($guidefaults, $el)), $category);
}
Esempio n. 15
0
 /**
  * get the Admin display in UCP
  * @param array $user The user array
  */
 public function getUCPAdminDisplay($user)
 {
     $fpbxusers = array();
     $cul = array();
     foreach (core_users_list() as $list) {
         $cul[$list[0]] = array("name" => $list[1], "vmcontext" => $list[2]);
     }
     $vmassigned = $this->FreePBX->Ucp->getSetting($user['username'], 'Voicemail', 'assigned');
     $vmassigned = !empty($vmassigned) ? $vmassigned : array();
     foreach ($user['assigned'] as $assigned) {
         $fpbxusers[] = array("ext" => $assigned, "data" => $cul[$assigned], "selected" => in_array($assigned, $vmassigned));
     }
     $html['description'] = '<a href="#" class="info">' . _("Allowed Voicemail") . ':<span>' . _("These are the assigned and active extensions which will show up for this user to control and edit in UCP") . '</span></a>';
     $html['content'] = load_view(dirname(__FILE__) . "/views/ucp_config.php", array("fpbxusers" => $fpbxusers));
     return $html;
 }
Esempio n. 16
0
function voicemail_dialvoicemail($c)
{
    global $ext, $amp_conf, $astman;
    $id = "app-dialvm";
    // The context to be included
    $ext->addInclude('from-internal-additional', $id);
    // Add the include from from-internal
    $ext->add($id, $c, '', new ext_macro('user-callerid'));
    $ext->add($id, $c, '', new ext_answer(''));
    $ext->add($id, $c, 'start', new ext_wait('1'));
    $ext->add($id, $c, '', new ext_noop($id . ': Asking for mailbox'));
    $ext->add($id, $c, '', new ext_read('MAILBOX', 'vm-login', '', '', 3, 2));
    $ext->add($id, $c, 'check', new ext_noop($id . ': Got Mailbox ${MAILBOX}'));
    $ext->add($id, $c, '', new ext_macro('get-vmcontext', '${MAILBOX}'));
    $ext->add($id, $c, '', new ext_vmexists('${MAILBOX}@${VMCONTEXT}'));
    $ext->add($id, $c, '', new ext_gotoif('$["${VMBOXEXISTSSTATUS}" = "SUCCESS"]', 'good', 'bad'));
    $ext->add($id, $c, '', new ext_macro('hangupcall'));
    $ext->add($id, $c, 'good', new ext_noop($id . ': Good mailbox ${MAILBOX}@${VMCONTEXT}'));
    $ext->add($id, $c, '', new ext_vmmain('${MAILBOX}@${VMCONTEXT}'));
    $ext->add($id, $c, '', new ext_gotoif('$["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]', 'playret'));
    $ext->add($id, $c, '', new ext_macro('hangupcall'));
    $ext->add($id, $c, 'bad', new ext_noop($id . ': BAD mailbox ${MAILBOX}@${VMCONTEXT}'));
    $ext->add($id, $c, '', new ext_wait('1'));
    $ext->add($id, $c, '', new ext_noop($id . ': Asking for password so people can\'t probe for existence of a mailbox'));
    $ext->add($id, $c, '', new ext_read('FAKEPW', 'vm-password', '', '', 3, 2));
    $ext->add($id, $c, '', new ext_noop($id . ': Asking for mailbox again'));
    $ext->add($id, $c, '', new ext_read('MAILBOX', 'vm-incorrect-mailbox', '', '', 3, 2));
    $ext->add($id, $c, '', new ext_goto('check'));
    $ext->add($id, $c, '', new ext_macro('hangupcall'));
    $ext->add($id, $c, 'playret', new ext_playback('beep&you-will-be-transfered-menu&silence/1'));
    $ext->add($id, $c, '', new ext_goto('1', 'return', '${IVR_CONTEXT}'));
    //res_mwi_blf allows you to subscribe to voicemail hints, the following code generates the dialplan for doing so
    $resmwiblf_check = $astman->send_request('Command', array('Command' => 'module show like res_mwi_blf'));
    $resmwiblf_module = preg_match('/[1-9] modules loaded/', $resmwiblf_check['data']);
    if (!$resmwiblf_module) {
        $resmwiblf_check = $astman->send_request('Command', array('Command' => 'module show like res_mwi_devstate'));
        $resmwiblf_module = preg_match('/[1-9] modules loaded/', $resmwiblf_check['data']);
    }
    if ($resmwiblf_module && $amp_conf['USERESMWIBLF']) {
        $userlist = core_users_list();
        if (is_array($userlist)) {
            foreach ($userlist as $item) {
                $exten = core_users_get($item[0]);
                $vm = $exten['voicemail'] == "novm" || $exten['voicemail'] == "disabled" || $exten['voicemail'] == "" ? "novm" : $exten['extension'];
                if ($vm != "novm") {
                    $ext->add($id, $c . $vm, '', new ext_goto('1', 'dvm${EXTEN:' . strlen($c) . '}'));
                    $ext->addHint($id, $c . $vm, "MWI:{$vm}@" . $exten['voicemail']);
                }
            }
        }
        $c = '_dvm.';
    } else {
        // Note that with this one, it has paramters. So we have to add '_' to the start and '.' to the end
        // of $c
        $c = "_{$c}.";
    }
    $ext->add($id, $c, '', new ext_answer(''));
    // $cmd,1,Answer
    $ext->add($id, $c, '', new ext_wait('1'));
    // $cmd,n,Wait(1)
    // How long is the command? We need to strip that off the front
    $clen = strlen($c) - 2;
    $ext->add($id, $c, '', new ext_macro('get-vmcontext', '${EXTEN:' . $clen . '}'));
    $ext->add($id, $c, '', new ext_vmmain('${EXTEN:' . $clen . '}@${VMCONTEXT}'));
    // n,VoiceMailMain(${VMCONTEXT})
    $ext->add($id, $c, '', new ext_gotoif('$["${IVR_RETVM}" = "RETURN" & "${IVR_CONTEXT}" != ""]', '${IVR_CONTEXT},return,1'));
    $ext->add($id, $c, '', new ext_macro('hangupcall'));
    // $cmd,n,Macro(user-callerid)
}
Esempio n. 17
0
function core_devices_configpageinit($dispnum)
{
    global $currentcomponent, $amp_conf;
    if ($dispnum == 'devices' || $dispnum == 'extensions') {
        // Option lists used by the gui
        $currentcomponent->addoptlistitem('devicetypelist', 'fixed', _("Fixed"));
        $currentcomponent->addoptlistitem('devicetypelist', 'adhoc', _("Adhoc"));
        $currentcomponent->setoptlistopts('devicetypelist', 'sort', false);
        $currentcomponent->addoptlistitem('deviceuserlist', 'none', _("none"));
        $users = core_users_list();
        if (isset($users)) {
            foreach ($users as $auser) {
                $currentcomponent->addoptlistitem('deviceuserlist', $auser[0], $auser[0] . " (" . $auser[1] . ")");
            }
        }
        $currentcomponent->setoptlistopts('deviceuserlist', 'sort', false);
        // Add the 'process' functions
        $currentcomponent->addguifunc('core_devices_configpageload');
        $currentcomponent->addprocessfunc('core_devices_configprocess');
    }
}
Esempio n. 18
0
 public function usermanShowPage()
 {
     if (isset($_REQUEST['action'])) {
         $mode = $_REQUEST['action'] == "showgroup" || $_REQUEST['action'] == "addgroup" ? "group" : "user";
         switch ($_REQUEST['action']) {
             case 'showgroup':
                 $group = $this->getGroupByGID($_REQUEST['group']);
                 $ausers = array('self' => _("User Primary Extension"));
                 $users = core_users_list();
                 if (!empty($users) && is_array($users)) {
                     foreach ($users as $list) {
                         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
                     }
                 }
                 $sassigned = $this->Userman->getModuleSettingByGID($_REQUEST['group'], 'ucp|Settings', 'assigned');
                 $sassigned = !empty($sassigned) ? $sassigned : array();
                 return array(array("title" => "UCP", "rawname" => "ucp", "content" => load_view(dirname(__FILE__) . '/views/users_hook.php', array("mode" => $mode, "ausers" => $ausers, "sassigned" => $sassigned, "mHtml" => $this->constructModuleConfigPages('group', $group, $_REQUEST['action']), "user" => array(), "allowLogin" => $this->Userman->getModuleSettingByGID($_REQUEST['group'], 'ucp|Global', 'allowLogin'), "originate" => $this->Userman->getModuleSettingByGID($_REQUEST['group'], 'ucp|Global', 'originate')))));
                 break;
             case 'addgroup':
                 $ausers = array('self' => _("User Primary Extension"));
                 $users = core_users_list();
                 if (!empty($users) && is_array($users)) {
                     foreach ($users as $list) {
                         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
                     }
                 }
                 return array(array("title" => "UCP", "rawname" => "ucp", "content" => load_view(dirname(__FILE__) . '/views/users_hook.php', array("mode" => $mode, "ausers" => $ausers, "sassigned" => array('self'), "mHtml" => $this->constructModuleConfigPages('group', array(), $_REQUEST['action']), "user" => array(), "allowLogin" => true, "originate" => false))));
                 break;
             case 'showuser':
                 $user = $this->getUserByID($_REQUEST['user']);
                 if (!empty($_REQUEST['deletesession'])) {
                     $this->expireUserSession($_REQUEST['deletesession']);
                     $this->setUsermanMessage(_('Deleted User Session'), 'success');
                 }
                 $ausers = array();
                 $sassigned = $this->getSetting($user['username'], 'Settings', 'assigned');
                 $users = core_users_list();
                 if (!empty($users) && is_array($users)) {
                     foreach ($users as $list) {
                         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
                     }
                 }
                 $sassigned = !empty($sassigned) ? $sassigned : array();
                 return array(array("title" => "UCP", "rawname" => "ucp", "content" => load_view(dirname(__FILE__) . '/views/users_hook.php', array("mode" => $mode, "ausers" => $ausers, "sassigned" => $sassigned, "mHtml" => $this->constructModuleConfigPages('user', $user, $_REQUEST['action']), "user" => $user, "allowLogin" => FreePBX::create()->Userman->getModuleSettingByID($_REQUEST['user'], 'ucp|Global', 'allowLogin', true), "originate" => FreePBX::create()->Userman->getModuleSettingByID($_REQUEST['user'], 'ucp|Global', 'originate', true), "sessions" => $this->getUserSessions($user['id'])))));
                 break;
             case 'adduser':
                 $ausers = array();
                 $users = core_users_list();
                 if (!empty($users) && is_array($users)) {
                     foreach ($users as $list) {
                         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
                     }
                 }
                 return array(array("title" => "UCP", "rawname" => "ucp", "content" => load_view(dirname(__FILE__) . '/views/users_hook.php', array("mode" => $mode, "ausers" => $ausers, "sassigned" => array('self'), "mHtml" => $this->constructModuleConfigPages('user', array(), $_REQUEST['action']), "user" => array(), "allowLogin" => null, "originate" => null, "sessions" => array()))));
                 break;
             default:
                 break;
         }
     }
 }
Esempio n. 19
0
function userman_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    global $astman;
    $userman = FreePBX::create()->Userman;
    // Init vars from $_REQUEST[]
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $ext = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extn = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    if ($ext === '') {
        $extdisplay = $extn;
    } else {
        $extdisplay = $ext;
    }
    if ($action != 'del') {
        $usersC = array();
        // Initialize the array.
        foreach (core_users_list() as $user) {
            $usersC[] = $user[0];
        }
        $section = _("User Manager Settings");
        $category = "general";
        $usettings = $userman->getAuthAllPermissions();
        $allGroups = array();
        foreach ($userman->getAllGroups() as $g) {
            $allGroups[] = array("value" => $g['id'], "text" => $g['groupname']);
        }
        //Old Extension
        if ($extdisplay != '') {
            $userM = $userman->getUserByDefaultExtension($extdisplay);
            $selarray = array(array("value" => 'none', "text" => _('None')));
            if ($usettings['addUser']) {
                $selarray[] = array("value" => 'add', "text" => _('Create New User'));
            }
            if (!empty($userM)) {
                $selarray[] = array("value" => $userM['id'], "text" => $userM['username'] . " (" . _("Linked") . ")");
            }
            $userarray = array();
            $uUsers = array();
            foreach ($userman->getAllUsers() as $user) {
                $uUsers[] = $user['username'];
                if ($user['default_extension'] != 'none' && in_array($user['default_extension'], $usersC)) {
                    continue;
                }
                $userarray[] = array("value" => $user['id'], "text" => $user['username']);
            }
            $selarray = array_merge($selarray, $userarray);
            if (!empty($userM)) {
                $currentcomponent->addguielem($section, new gui_link('userman|' . $extdisplay, sprintf(_('Linked to User %s'), $userM['username']), '?display=userman&action=showuser&user='******'id']), $category);
                $currentcomponent->addguielem($section, new gui_selectbox('userman_assign', $selarray, $userM['id'], _('Link to a Different Default User:'******'Select a user that this extension should be linked to in User Manager, else select Create New User to have User Manager autogenerate a new user that will be linked to this extension'), false, 'frm_extensions_usermanPassword();'), $category);
                $groups = $userman->getGroupsByID($userM['id']);
                $groups = is_array($groups) ? $groups : array();
            } else {
                $currentcomponent->addguielem($section, new gui_selectbox('userman_assign', $selarray, '', _('Link to a Default User'), _('Select a user that this extension should be linked to in User Manager, else select Create New User to have User Manager autogenerate a new user that will be linked to this extension'), false, 'frm_' . $display . '_usermanPassword();'), $category);
                $groups = array();
            }
            $currentcomponent->addjsfunc('usermanUsername()', "if(\$('#userman_username_cb').prop('checked')) {var users = " . json_encode($uUsers) . "; if(isEmpty(\$('#userman_username').val()) || users.indexOf(\$('#userman_username').val()) >= 0) {return true;}} return false;");
            $ao = $userman->getAuthObject();
            $currentcomponent->addjsfunc('usermanPassword()', "if(\$('#userman_assign').val() != 'none') {\$('#userman_group').prop('disabled',false)} else {\$('#userman_group').prop('disabled',true)} \$('#userman_group').trigger('chosen:updated'); if(\$('#userman_assign').val() != 'add') {var id = \$('#userman_assign').val(); var groups = " . json_encode($userman->getAllGroups()) . "; var fg = []; \$.each(groups, function(i,v) { if(v.users.indexOf(id) > -1) { fg.push(v.id) } }); \$('#userman_group').val(fg); \$('#userman_group').trigger('chosen:updated'); \$('#userman_password').attr('disabled',true);if(\$('#userman_username_cb').prop('checked')) { \$('#userman_username_cb').click() }\$('#userman_username_cb').attr('disabled',true);} else { var d = " . json_encode($ao->getDefaultGroups()) . "; \$('#userman_group').val(d); \$('#userman_group').trigger('chosen:updated'); if(\$('#userman_assign option[value=\"" . $extdisplay . "\"]').length == 0){\$('#userman_username_cb').click();}\$('#userman_password').attr('disabled',false);\$('#userman_username_cb').attr('disabled',false)}");
            if ($usettings['addUser']) {
                $currentcomponent->addguielem($section, new gui_textbox_check('userman_username', '', _('Username'), _('If Create New User is selected this will be the username. If blank the username will be the same number as this device'), 'frm_' . $display . '_usermanUsername()', _("Please select a valid username for New User Creation"), false, 0, true, _('Use Custom Username'), ""), $category);
                $currentcomponent->addguielem($section, new gui_textbox('userman_password', md5(uniqid()), _('Password For New User'), _('If Create New User is selected this will be the autogenerated users new password'), '', '', false, 0, true, false, 'password-meter', false), $category);
            }
            if ($usettings['modifyGroup']) {
                $currentcomponent->addguielem($section, new gui_multiselectbox('userman_group', $allGroups, $groups, _('Groups'), _('Groups that this user is a part of. You can add and remove this user from groups in this view as well'), false, '', empty($userM), "chosenmultiselect"), $category);
            }
        } else {
            //New Extension
            $selarray = array(array("value" => 'none', "text" => _('None')));
            if ($usettings['addUser']) {
                $selarray[] = array("value" => "add", "text" => _('Create New User'));
            }
            $uUsers = array();
            foreach ($userman->getAllUsers() as $user) {
                $uUsers[] = $user['username'];
                if ($user['default_extension'] != 'none' && in_array($user['default_extension'], $usersC)) {
                    continue;
                }
                $selarray[] = array("value" => $user['id'], "text" => $user['username']);
            }
            $currentcomponent->addjsfunc('usermanUsername()', "if(\$('#userman_username_cb').prop('checked')) {var users = " . json_encode($uUsers) . "; if(isEmpty(\$('#userman_username').val()) || users.indexOf(\$('#userman_username').val()) >= 0) {return true;}} return false;");
            $ao = $userman->getAuthObject();
            $dgroups = $ao->getDefaultGroups();
            $currentcomponent->addjsfunc('usermanPassword()', "if(\$('#userman_assign').val() != 'none') {\$('#userman_group').prop('disabled',false)} else {\$('#userman_group').prop('disabled',true)} \$('#userman_group').trigger('chosen:updated'); if(\$('#userman_assign').val() != 'add') {var id = \$('#userman_assign').val(); var groups = " . json_encode($userman->getAllGroups()) . "; var fg = []; \$.each(groups, function(i,v) { if(v.users.indexOf(id) > -1) { fg.push(v.id) } }); \$('#userman_group').val(fg); \$('#userman_group').trigger('chosen:updated'); \$('#userman_password').attr('disabled',true);if(\$('#userman_username_cb').prop('checked')) { \$('#userman_username_cb').click() }\$('#userman_username_cb').attr('disabled',true);} else {var d = " . json_encode($dgroups) . "; \$('#userman_group').val(d); \$('#userman_group').trigger('chosen:updated'); \$('#userman_password').attr('disabled',false);\$('#userman_username_cb').attr('disabled',false)}");
            $currentcomponent->addguielem($section, new gui_selectbox('userman_assign', $selarray, 'add', _('Link to a Default User'), _('Select a user that this extension should be linked to in User Manager, else select None to have no association to a user'), false, 'frm_extensions_usermanPassword()'), $category);
            if ($usettings['addUser']) {
                $currentcomponent->addguielem($section, new gui_textbox_check('userman_username', '', _('Username'), _('If Create New User is selected this will be the username. If blank the username will be the same number as this device'), 'frm_' . $display . '_usermanUsername()', _("Please select a valid username for New User Creation"), false, 0, true, _('Use Custom Username'), ""), $category);
                $currentcomponent->addguielem($section, new gui_textbox('userman_password', md5(uniqid()), _('Password For New User'), _('If Create New User is selected this will be the autogenerated users new password'), '', '', false, 0, false, false, 'password-meter', false), $category);
            }
            if ($usettings['modifyGroup']) {
                $groups = !empty($groups) && is_array($groups) ? $groups : array();
                $currentcomponent->addguielem($section, new gui_multiselectbox('userman_group', $allGroups, $dgroups, _('Groups'), _('Groups that this user is a part of. You can add and remove this user from groups in this view as well'), false, '', false, "chosenmultiselect"), $category);
            }
        }
    } else {
        //unassign all extensions for this user
        foreach ($userman->getAllUsers() as $user) {
            $assigned = $userman->getGlobalSettingByID($user['id'], 'assigned');
            $assigned = is_array($assigned) ? $assigned : array();
            $assigned = array_diff($assigned, array($extdisplay));
            $userman->setGlobalSettingByID($user['id'], 'assigned', $assigned);
        }
    }
}
Esempio n. 20
0
 public function usermanShowPage()
 {
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'showgroup':
             case 'addgroup':
             case 'adduser':
             case 'showuser':
                 $enabled = null;
                 if ($_REQUEST['action'] == "showuser") {
                     $enabled = $this->userman->getModuleSettingByID($_REQUEST['user'], 'restapi', 'restapi_token_status', true);
                     $tokens = restapi_user_get_user_tokens($_REQUEST['user']);
                 } else {
                     $tokens = array();
                 }
                 $displayvars = array("mode" => in_array($_REQUEST['action'], array("showgroup", "addgroup")) ? "group" : "user", "enabled" => $enabled);
                 $tokens = !empty($tokens) ? $tokens : array();
                 $displayvars['user_list_all'] = array();
                 if (in_array($_REQUEST['action'], array("showgroup", "addgroup"))) {
                     $displayvars['user_list_all']['self'] = _("User Primary Extension");
                 }
                 $cul = array();
                 foreach (core_users_list() as $list) {
                     $cul[$list[0]] = array("name" => $list[1], "vmcontext" => $list[2]);
                     $displayvars['user_list_all'][$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
                 }
                 // Get list of modules that have been API enabled.
                 $api = new \Api();
                 $api_mods = array();
                 foreach ($api->maps as $verb => $urls) {
                     foreach ($urls as $url => $maps) {
                         foreach ($maps as $map => $details) {
                             $api_mods[$details["module"]] = 1;
                         }
                     }
                 }
                 unset($api);
                 //modules
                 global $db;
                 $mods = \modulelist::create($db);
                 $displayvars['module_list'] = array();
                 foreach ($mods->module_array as $mod) {
                     if (isset($mod['rawname']) && isset($api_mods[$mod['rawname']])) {
                         $displayvars['module_list'][$mod['rawname']] = $mod['name'];
                     }
                 }
                 asort($displayvars['module_list']);
                 $displayvars['module_list'] = array('*' => _('All')) + $displayvars['module_list'];
                 //everything else
                 $rest_template = $displayvars;
                 if (!empty($tokens)) {
                     foreach ($tokens as $token) {
                         $displayvars['tokens'][] = array_merge($rest_template, restapi_tokens_get($token));
                     }
                 } else {
                     $displayvars['tokens'][0] = array_merge($rest_template, restapi_tokens_get());
                     $displayvars['tokens'][0]['token'] = \restapi_tokens_generate();
                     $displayvars['tokens'][0]['tokenkey'] = \restapi_tokens_generate();
                     $displayvars['tokens'][0]['id'] = 0;
                     $displayvars['tokens'][0]['users'] = array("self");
                     $displayvars['tokens'][0]['rate'] = 1000;
                 }
                 if ($displayvars['mode'] == "user") {
                 } else {
                     //group mode
                     $enabled = $this->userman->getModuleSettingByGID($_REQUEST['group'], 'restapi', 'restapi_token_status');
                     $users = $this->userman->getModuleSettingByGID($_REQUEST['group'], 'restapi', 'restapi_users');
                     $modules = $this->userman->getModuleSettingByGID($_REQUEST['group'], 'restapi', 'restapi_modules');
                     $rate = $this->userman->getModuleSettingByGID($_REQUEST['group'], 'restapi', 'restapi_rate');
                     $displayvars['tokens'][0] = array_merge($rest_template, restapi_tokens_get());
                     $displayvars['tokens'][0]['token'] = 1;
                     $displayvars['tokens'][0]['tokenkey'] = 1;
                     $displayvars['tokens'][0]['id'] = 0;
                     if (!$enabled) {
                         $displayvars['tokens'][0]['users'] = is_array($users) ? $users : array("self");
                         $displayvars['enabled'] = $enabled;
                     } else {
                         $displayvars['tokens'][0]['users'] = is_array($users) ? $users : array("self");
                         $displayvars['tokens'][0]['rate'] = !empty($rate) ? $rate : "1000";
                         $displayvars['tokens'][0]['modules'] = is_array($modules) ? $modules : array();
                         $displayvars['enabled'] = $enabled;
                     }
                 }
                 return array(array("title" => _("Rest API"), "rawname" => "restapi", "content" => load_view(__DIR__ . '/views/hook_userman.php', $displayvars)));
                 break;
         }
     }
 }
Esempio n. 21
0
function paging_get_config($engine)
{
    global $db;
    global $ext;
    global $chan_dahdi;
    global $version;
    switch ($engine) {
        case "asterisk":
            $ast_ge_16 = version_compare($version, "1.6", "ge");
            // setup for intercom
            $fcc = new featurecode('paging', 'intercom-prefix');
            $intercom_code = $fcc->getCodeActive();
            unset($fcc);
            // Since these are going down channel local, set ALERT_INFO and SIPADDHEADER which will be set in dialparties.agi
            // no point in even setting the headers here they will get lost in channel local
            //
            /* Set these up once here and in intercom so that autoanswer macro does not have
             * to go through this for every single extension which causes a lot of extra overhead
             * with big page groups
             */
            $has_answermacro = false;
            $alertinfo = 'Alert-Info: Ring Answer';
            $callinfo = 'Call-Info: <uri>\\;answer-after=0';
            $sipuri = 'intercom=true';
            $doptions = 'A(beep)';
            $dtime = '5';
            $custom_vars = array();
            $autoanswer_arr = paging_get_autoanswer_defaults();
            foreach ($autoanswer_arr as $autosetting) {
                switch (trim($autosetting['var'])) {
                    case 'ALERTINFO':
                        $alertinfo = trim($autosetting['setting']);
                        break;
                    case 'CALLINFO':
                        $callinfo = trim($autosetting['setting']);
                        break;
                    case 'SIPURI':
                        $sipuri = trim($autosetting['setting']);
                        break;
                    case 'VXML_URL':
                        $vxml_url = trim($autosetting['setting']);
                        break;
                    case 'DOPTIONS':
                        $doptions = trim($autosetting['setting']);
                        break;
                    case 'DTIME':
                        $dtime = trim($autosetting['setting']);
                        break;
                    default:
                        $key = trim($autosetting['var']);
                        $custom_vars[$key] = trim($autosetting['setting']);
                        if (ltrim($custom_vars[$key], '_') == "ANSWERMACRO") {
                            $has_answermacro = true;
                        }
                        break;
                }
            }
            $extpaging = 'ext-paging';
            if (!empty($intercom_code)) {
                $code = '_' . $intercom_code . '.';
                $context = 'ext-intercom';
                $ext->add($context, $code, '', new ext_macro('user-callerid'));
                $ext->add($context, $code, '', new ext_setvar('dialnumber', '${EXTEN:' . strlen($intercom_code) . '}'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/intercom/block)}" = "blocked"]', 'end'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DB(DND/${dialnumber})}" = "YES"]', 'end'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DB(AMPUSER/${dialnumber}/intercom/${AMPUSER})}" = "allow" ]', 'allow'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DB(AMPUSER/${dialnumber}/intercom/${AMPUSER})}" = "deny" ]', 'nointercom'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DB(AMPUSER/${dialnumber}/intercom)}" = "disabled" ]', 'nointercom'));
                $ext->add($context, $code, 'allow', new ext_dbget('DEVICES', 'AMPUSER/${dialnumber}/device'));
                $ext->add($context, $code, '', new ext_gotoif('$["${DEVICES}" = "" ]', 'end'));
                $ext->add($context, $code, '', new ext_setvar('LOOPCNT', '${FIELDQTY(DEVICES,&)}'));
                /* Set these up so that macro-autoanswer doesn't have to
                 */
                $ext->add($context, $code, '', new ext_setvar('_SIPURI', ''));
                if (trim($alertinfo) != "") {
                    $ext->add($context, $code, '', new ext_setvar('_ALERTINFO', $alertinfo));
                }
                if (trim($callinfo) != "") {
                    $ext->add($context, $code, '', new ext_setvar('_CALLINFO', $callinfo));
                }
                if (trim($sipuri) != "") {
                    $ext->add($context, $code, '', new ext_setvar('_SIPURI', $sipuri));
                }
                if (trim($vxml_url) != "") {
                    $ext->add($context, $code, '', new ext_setvar('_VXML_URL', $vxml_url));
                }
                if (trim($doptions) != "") {
                    $ext->add($context, $code, '', new ext_setvar('_DOPTIONS', $doptions));
                }
                foreach ($custom_vars as $key => $value) {
                    $ext->add($context, $code, '', new ext_setvar('_' . ltrim($key, '_'), $value));
                }
                $ext->add($context, $code, '', new ext_setvar('_DTIME', $dtime));
                $ext->add($context, $code, '', new ext_setvar('_ANSWERMACRO', ''));
                $ext->add($context, $code, '', new ext_gotoif('$[${LOOPCNT} > 1 ]', 'pagemode'));
                $ext->add($context, $code, '', new ext_macro('autoanswer', '${DEVICES}'));
                if ($ast_ge_16) {
                    $ext->add($context, $code, 'check', new ext_chanisavail('${DIAL}', 's'));
                    $ext->add($context, $code, '', new ext_gotoif('$["${AVAILORIGCHAN}" == ""]', 'end'));
                } else {
                    $ext->add($context, $code, 'check', new ext_chanisavail('${DIAL}', 'sj'));
                }
                $ext->add($context, $code, '', new ext_dial('${DIAL}', '${DTIME},${DOPTIONS}'));
                $ext->add($context, $code, 'end', new ext_busy());
                $ext->add($context, $code, '', new ext_macro('hangupcall'));
                if (!$ast_ge_16) {
                    $ext->add($context, $code, '', new ext_busy(), 'check', 101);
                    $ext->add($context, $code, '', new ext_macro('hangupcall'));
                }
                $ext->add($context, $code, 'pagemode', new ext_setvar('ITER', '1'));
                $ext->add($context, $code, '', new ext_setvar('DIALSTR', ''));
                $ext->add($context, $code, 'begin', new ext_setvar('DIALSTR', '${DIALSTR}&LOCAL/PAGE${CUT(DEVICES,&,${ITER})}@' . $extpaging));
                $ext->add($context, $code, '', new ext_setvar('ITER', '$[${ITER} + 1]'));
                $ext->add($context, $code, '', new ext_gotoif('$[${ITER} <= ${LOOPCNT}]', 'begin'));
                $ext->add($context, $code, '', new ext_setvar('DIALSTR', '${DIALSTR:1}'));
                $ext->add($context, $code, '', new ext_setvar('_AMPUSER', '${AMPUSER}'));
                $ext->add($context, $code, '', new ext_page('${DIALSTR},d'));
                $ext->add($context, $code, '', new ext_busy());
                $ext->add($context, $code, '', new ext_macro('hangupcall'));
                $ext->add($context, $code, 'nointercom', new ext_noop('Intercom disallowed by ${dialnumber}'));
                $ext->add($context, $code, '', new ext_playback('intercom&for&extension'));
                $ext->add($context, $code, '', new ext_saydigits('${dialnumber}'));
                $ext->add($context, $code, '', new ext_playback('is&disabled'));
                $ext->add($context, $code, '', new ext_congestion());
                $extintercomusers = 'ext-intercom-users';
                $userlist = core_users_list();
                if (is_array($userlist)) {
                    foreach ($userlist as $item) {
                        $ext_intercom_code = $intercom_code . $item[0];
                        $ext->add($extintercomusers, $ext_intercom_code, '', new ext_goto($context . ',${EXTEN},1'));
                    }
                }
                $context = $extintercomusers;
                $ext->addInclude('from-internal-additional', $context);
            }
            $fcc = new featurecode('paging', 'intercom-on');
            $oncode = $fcc->getCodeActive();
            unset($fcc);
            if ($oncode) {
                $ext->add($context, $oncode, '', new ext_answer(''));
                $ext->add($context, $oncode, '', new ext_wait('1'));
                $ext->add($context, $oncode, '', new ext_macro('user-callerid'));
                $ext->add($context, $oncode, '', new ext_setvar('DB(AMPUSER/${AMPUSER}/intercom)', 'enabled'));
                $ext->add($context, $oncode, '', new ext_playback('intercom&enabled'));
                $ext->add($context, $oncode, '', new ext_macro('hangupcall'));
                $target = '${EXTEN:' . strlen($oncode) . '}';
                $oncode = "_" . $oncode . ".";
                $ext->add($context, $oncode, '', new ext_answer(''));
                $ext->add($context, $oncode, '', new ext_wait('1'));
                $ext->add($context, $oncode, '', new ext_macro('user-callerid'));
                $ext->add($context, $oncode, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/intercom/' . $target . ')}" = "allow" ]}', 'unset'));
                $ext->add($context, $oncode, '', new ext_gotoif('$[${DB_EXISTS(AMPUSER/${EXTEN:3}/device)} != 1]', 'invaliduser'));
                $ext->add($context, $oncode, '', new ext_dbput('AMPUSER/${AMPUSER}/intercom/' . $target, 'allow'));
                $ext->add($context, $oncode, '', new ext_playback('intercom&enabled&for&extension&number'));
                $ext->add($context, $oncode, '', new ext_saydigits($target));
                $ext->add($context, $oncode, '', new ext_macro('hangupcall'));
                $ext->add($context, $oncode, 'unset', new ext_dbdeltree('AMPUSER/${AMPUSER}/intercom/' . $target));
                $ext->add($context, $oncode, '', new ext_playback('intercom&enabled&cancelled&for&extension&number'));
                $ext->add($context, $oncode, '', new ext_saydigits($target));
                $ext->add($context, $oncode, '', new ext_macro('hangupcall'));
                $ext->add($context, $oncode, 'invaliduser', new ext_playback('extension&number'));
                $ext->add($context, $oncode, '', new ext_saydigits($target));
                $ext->add($context, $oncode, '', new ext_playback('is&invalid'));
                $ext->add($context, $oncode, '', new ext_macro('hangupcall'));
            }
            $fcc = new featurecode('paging', 'intercom-off');
            $offcode = $fcc->getCodeActive();
            unset($fcc);
            if ($offcode) {
                $ext->add($context, $offcode, '', new ext_answer(''));
                $ext->add($context, $offcode, '', new ext_wait('1'));
                $ext->add($context, $offcode, '', new ext_macro('user-callerid'));
                $ext->add($context, $offcode, '', new ext_setvar('DB(AMPUSER/${AMPUSER}/intercom)', 'disabled'));
                $ext->add($context, $offcode, '', new ext_playback('intercom&disabled'));
                $ext->add($context, $offcode, '', new ext_macro('hangupcall'));
                $target = '${EXTEN:' . strlen($offcode) . '}';
                $offcode = "_" . $offcode . ".";
                $ext->add($context, $offcode, '', new ext_answer(''));
                $ext->add($context, $offcode, '', new ext_wait('1'));
                $ext->add($context, $offcode, '', new ext_macro('user-callerid'));
                $ext->add($context, $offcode, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/intercom/' . $target . ')}" = "deny" ]}', 'unset2'));
                $ext->add($context, $offcode, '', new ext_gotoif('$[${DB_EXISTS(AMPUSER/${EXTEN:3}/device)} != 1]', 'invaliduser2'));
                $ext->add($context, $offcode, '', new ext_dbput('AMPUSER/${AMPUSER}/intercom/' . $target, 'deny'));
                $ext->add($context, $offcode, '', new ext_playback('intercom&disabled&for&extension&number'));
                $ext->add($context, $offcode, '', new ext_saydigits($target));
                $ext->add($context, $offcode, '', new ext_macro('hangupcall'));
                $ext->add($context, $offcode, 'unset2', new ext_dbdeltree('AMPUSER/${AMPUSER}/intercom/' . $target));
                $ext->add($context, $offcode, '', new ext_playback('intercom&disabled&cancelled&for&extension&number'));
                $ext->add($context, $offcode, '', new ext_saydigits($target));
                $ext->add($context, $offcode, '', new ext_macro('hangupcall'));
                $ext->add($context, $offcode, 'invaliduser2', new ext_playback('extension&number'));
                $ext->add($context, $offcode, '', new ext_saydigits($target));
                $ext->add($context, $offcode, '', new ext_playback('is&invalid'));
                $ext->add($context, $offcode, '', new ext_macro('hangupcall'));
            }
            /* Create macro-autoanswer that will try to intelligently set the
            		   	required parameters to handle paging. Eventually it will use
            			 	known device information.
            
            				This macro does the following:
            
            				Input:  FreePBX Device number to be called requiring autoanswer
            				Output: ${DIAL} Channel Variable with the dial string to be called
            				        Appropriate SIP headers added
            								Other special requirements that may be custom for this device
            
            				1. Set ${DIAL} to the device's dial string
            				2. If there is a device specific macro defined in the DEVICE's object
            				   (DEVICE/<devicenum>/autoanswer/macro) then execute that macro and end
            				3. Try to identify endpoints by their useragents that may need known
            				   changes and make those changes. These are generated from the
            					 paging_autoanswer table so users can extend them, if any are present
            				5. Set the variables and end unless a useragent specific ANSWERMACRO is
            				   defined in which case call it and end.
            
            				This macro is called for intercoming and paging to try and enable the
            				target device to auto-answer. Devices with special needs can be handled
            				with the device specific macro. For example, if you have a device that
            				can not auto-answer except by specifically configuring a line key on
            				the device that always answers, you could use a device specific macro
            				to change the dialstring. If you had a set of such devices, you could
            				standardize on the device numbers (e.g. nnnn for normal calls and 2nnnn
            				for auto-answer calls). You could then create a general purpose macro
            				to modify the dial string accordingly. Provisioning tools will be able
            				to take advantage of setting and creating such an ability.
            				If you have a set of devices that can be identified with a SIP useragent
            				then you can use a general macro without setting info in each device.
            		 	*/
            $autoanswer_arr = paging_get_autoanswer_useragents();
            $macro = 'macro-autoanswer';
            $ext->add($macro, "s", '', new ext_setvar('DIAL', '${DB(DEVICE/${ARG1}/dial)}'));
            // If we are in DAHDI compat mode, then we need to substitute DAHDI for ZAP
            if ($chan_dahdi) {
                $ext->add($macro, "s", '', new ext_execif('$["${DIAL:0:3}" = "ZAP"]', 'Set', 'DIAL=DAHDI${DIAL:3}'));
            }
            $ext->add($macro, "s", '', new ext_gotoif('$["${DB(DEVICE/${ARG1}/autoanswer/macro)}" != "" ]', 'macro'));
            // If there are no phone specific auto-answer vars, then we don't care what the phone is below
            //
            if (!empty($autoanswer_arr)) {
                $ext->add($macro, "s", '', new ext_setvar('phone', '${SIPPEER(${CUT(DIAL,/,2)}:useragent)}'));
            }
            // We used to set all the variables here (ALERTINFO, CALLINFO, etc. That has been moved to each
            // paging group and the intercom main macro, since it was redundant for every phone causing a lot
            // of overhead with large page groups.
            //
            // Defaults are setup, now make specific adjustments for detected phones
            // These come from the SQL table as well where installations can make customizations
            //
            foreach ($autoanswer_arr as $autosetting) {
                $useragent = trim($autosetting['useragent']);
                $autovar = trim($autosetting['var']);
                $data = trim($autosetting['setting']);
                switch (ltrim($autovar, '_')) {
                    case 'ANSWERMACRO':
                        $has_answermacro = true;
                        // fall through - no break on purpose
                    // fall through - no break on purpose
                    case 'ALERTINFO':
                    case 'CALLINFO':
                    case 'SIPURI':
                    case 'VXML_URL':
                    case 'DOPTIONS':
                    case 'DTIME':
                    default:
                        if (trim($data) != "") {
                            $ext->add($macro, "s", '', new ext_execif('$["${phone:0:' . strlen($useragent) . '}" = "' . $useragent . '"]', 'Set', $autovar . '=' . $data));
                        }
                        break;
                }
            }
            // Now any adjustments have been made, set the headers and done
            //
            if ($has_answermacro) {
                $ext->add($macro, "s", '', new ext_gotoif('$["${ANSWERMACRO}" != ""]', 'macro2'));
            }
            $ext->add($macro, "s", '', new ext_execif('$["${ALERTINFO}" != ""]', 'SipAddHeader', '${ALERTINFO}'));
            $ext->add($macro, "s", '', new ext_execif('$["${CALLINFO}" != ""]', 'SipAddHeader', '${CALLINFO}'));
            $ext->add($macro, "s", '', new ext_execif('$["${SIPURI}" != ""]', 'Set', '__SIP_URI_OPTIONS=${SIPURI}'));
            $ext->add($macro, "s", 'macro', new ext_macro('${DB(DEVICE/${ARG1}/autoanswer/macro)}', '${ARG1}'), 'n', 2);
            if ($has_answermacro) {
                $ext->add($macro, "s", 'macro2', new ext_macro('${ANSWERMACRO}', '${ARG1}'), 'n', 2);
            }
            // Create the paging context that is used in the paging application for each phone to auto-answer
            //
            $ext->addInclude('from-internal-additional', $extpaging);
            // Normal page version
            $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$[ ${AMPUSER} = ${EXTEN:4} ]', 'skipself'));
            if ($ast_ge_16) {
                $ext->add($extpaging, "_PAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:4}/dial)}', 's'));
                $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$["${AVAILORIGCHAN}" == ""]', 'skipself'));
            } else {
                $ext->add($extpaging, "_PAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:4}/dial)}', 'js'));
            }
            $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$["${DB(DND/${DB(DEVICE/${EXTEN:4}/user)})}" = "YES"]', 'skipself'));
            $ext->add($extpaging, "_PAGE.", 'SKIPCHECK', new ext_macro('autoanswer', '${EXTEN:4}'));
            $ext->add($extpaging, "_PAGE.", '', new ext_dial('${DIAL}', '${DTIME},${DOPTIONS}'));
            $ext->add($extpaging, "_PAGE.", 'skipself', new ext_hangup());
            if (!$ast_ge_16) {
                $ext->add($extpaging, "_PAGE.", '', new ext_hangup(''), 'AVAIL', 101);
            }
            // Force page version
            $ext->add($extpaging, "_FPAGE.", '', new ext_gotoif('$[ ${AMPUSER} = ${EXTEN:5} ]', 'skipself'));
            $ext->add($extpaging, "_FPAGE.", 'SKIPCHECK', new ext_macro('autoanswer', '${EXTEN:5}'));
            $ext->add($extpaging, "_FPAGE.", '', new ext_dial('${DIAL}', '${DTIME},${DOPTIONS}'));
            $ext->add($extpaging, "_FPAGE.", 'skipself', new ext_hangup());
            //
            // Now get a list of all the paging groups...
            $sql = "SELECT page_group, force_page, duplex FROM paging_config";
            $paging_groups = $db->getAll($sql, DB_FETCHMODE_ASSOC);
            foreach ($paging_groups as $thisgroup) {
                $grp = trim($thisgroup['page_group']);
                $pagemode = $thisgroup['force_page'] ? 'FPAGE' : 'PAGE';
                $sql = "SELECT ext FROM paging_groups WHERE page_number='{$grp}'";
                $all_exts = $db->getAll($sql);
                $dialstr = '';
                foreach ($all_exts as $local_dial) {
                    if (strtoupper(substr($local_dial[0], -1)) == "X") {
                        $local_dial[0] = rtrim($local_dial[0], "xX");
                    }
                    $dialstr .= "LOCAL/{$pagemode}" . trim($local_dial[0]) . "@" . $extpaging . "&";
                }
                // It will always end with an &, so lets take that off.
                $dialstr = rtrim($dialstr, "&");
                if ($thisgroup['duplex']) {
                    $dialstr .= ",d";
                }
                $ext->add($extpaging, $grp, '', new ext_answer(''));
                $ext->add($extpaging, $grp, '', new ext_macro('user-callerid'));
                // make AMPUSER inherited here, so we can skip the proper 'self' if using cidnum masquerading
                $ext->add($extpaging, $grp, '', new ext_setvar('_AMPUSER', '${AMPUSER}'));
                $ext->add($extpaging, $grp, '', new ext_setvar('_SIPURI', ''));
                if (trim($alertinfo) != "") {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_ALERTINFO', $alertinfo));
                }
                if (trim($callinfo) != "") {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_CALLINFO', $callinfo));
                }
                if (trim($sipuri) != "") {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_SIPURI', $sipuri));
                }
                if (trim($vxml_url) != "") {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_VXML_URL', $vxml_url));
                }
                if (trim($doptions) != "") {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_DOPTIONS', $doptions));
                }
                $ext->add($extpaging, $grp, '', new ext_setvar('_DTIME', $dtime));
                $ext->add($extpaging, $grp, '', new ext_setvar('_ANSWERMACRO', ''));
                foreach ($custom_vars as $key => $value) {
                    $ext->add($extpaging, $grp, '', new ext_setvar('_' . ltrim($key, '_'), $value));
                }
                $ext->add($extpaging, $grp, '', new ext_setvar('__FORWARD_CONTEXT', 'block-cf'));
                $ext->add($extpaging, $grp, '', new ext_page($dialstr));
            }
            break;
    }
}
Esempio n. 22
0
function userman_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    global $astman;
    $userman = setup_userman();
    // Init vars from $_REQUEST[]
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $ext = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extn = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    if ($ext === '') {
        $extdisplay = $extn;
    } else {
        $extdisplay = $ext;
    }
    if ($action != 'del') {
        $usersC = array();
        // Initialize the array.
        foreach (core_users_list() as $user) {
            $usersC[] = $user[0];
        }
        if ($extdisplay != '') {
            $section = _("User Manager Settings");
            $userM = $userman->getUserByDefaultExtension($extdisplay);
            if (!empty($userM)) {
                $selarray = array(array("value" => 'none', "text" => _('None')), array("value" => 'add', "text" => _('Create New User')), array("value" => $userM['id'], "text" => $userM['username'] . " (" . _("Linked") . ")"));
            } else {
                $selarray = array(array("value" => 'none', "text" => _('None')), array("value" => 'add', "text" => _('Create New User')));
            }
            $userarray = array();
            $uUsers = array();
            foreach ($userman->getAllUsers() as $user) {
                $uUsers[] = $user['username'];
                if ($user['default_extension'] != 'none' && in_array($user['default_extension'], $usersC)) {
                    continue;
                }
                $userarray[] = array("value" => $user['id'], "text" => $user['username']);
            }
            $selarray = array_merge($selarray, $userarray);
            if (!empty($userM)) {
                $currentcomponent->addguielem($section, new gui_link('userman|' . $extdisplay, sprintf(_('Linked to User %s'), $userM['username']), '?display=userman&action=showuser&user='******'id']));
                $currentcomponent->addguielem($section, new gui_selectbox('userman|assign', $selarray, $userM['id'], _('Link to a Different Default User:'******'Select a user that this extension should be linked to in User Manager, else select Create New User to have User Manager autogenerate a new user that will be linked to this extension'), false, 'frm_extensions_usermanPassword();'));
            } else {
                $currentcomponent->addguielem($section, new gui_selectbox('userman|assign', $selarray, '', _('Link to a Default User:'******'Select a user that this extension should be linked to in User Manager, else select Create New User to have User Manager autogenerate a new user that will be linked to this extension'), false, 'frm_' . $display . '_usermanPassword();'));
            }
            $currentcomponent->addjsfunc('usermanUsername()', "if(\$('#userman_username_cb').prop('checked')) {var users = " . json_encode($uUsers) . "; if(isEmpty(\$('#userman_username').val()) || users.indexOf(\$('#userman_username').val()) >= 0) {return true;}} return false;");
            $currentcomponent->addjsfunc('usermanPassword()', "if(\$('#userman\\\\|assign').val() != 'add') {\$('#userman\\\\|password').attr('disabled',true);if(\$('#userman_username_cb').prop('checked')) { \$('#userman_username_cb').click() }\$('#userman_username_cb').attr('disabled',true);} else {\$('#userman\\\\|password').attr('disabled',false);\$('#userman_username_cb').attr('disabled',false)}");
            $currentcomponent->addguielem($section, new gui_textbox_check('userman_username', '', _('Username'), _('If Create New User is selected this will be the username. If blank the username will be the same number as this device'), 'frm_' . $display . '_usermanUsername()', _("Please select a valid username for New User Creation"), false, 0, true, _('Use Custom Username'), ""));
            $currentcomponent->addguielem($section, new gui_textbox('userman|password', md5(uniqid()), _('Password For New User'), _('If Create New User is selected this will be the autogenerated users new password'), '', '', false, 0, true));
        } else {
            $section = _("User Manager Settings");
            $selarray = array(array("value" => 'none', "text" => _('None')), array("value" => "add", "text" => _('Create New User')));
            $uUsers = array();
            foreach ($userman->getAllUsers() as $user) {
                $uUsers[] = $user['username'];
                if ($user['default_extension'] != 'none' && in_array($user['default_extension'], $usersC)) {
                    continue;
                }
                $selarray[] = array("value" => $user['id'], "text" => $user['username']);
            }
            $currentcomponent->addjsfunc('usermanUsername()', "if(\$('#userman_username_cb').prop('checked')) {var users = " . json_encode($uUsers) . "; if(isEmpty(\$('#userman_username').val()) || users.indexOf(\$('#userman_username').val()) >= 0) {return true;}} return false;");
            $currentcomponent->addjsfunc('usermanPassword()', "if(\$('#userman\\\\|assign').val() != 'add') {\$('#userman\\\\|password').attr('disabled',true);if(\$('#userman_username_cb').prop('checked')) { \$('#userman_username_cb').click() }\$('#userman_username_cb').attr('disabled',true);} else {\$('#userman\\\\|password').attr('disabled',false);\$('#userman_username_cb').attr('disabled',false)}");
            $currentcomponent->addguielem($section, new gui_selectbox('userman|assign', $selarray, 'add', _('Link to a Default User:'******'Select a user that this extension should be linked to in User Manager, else select None to have no association to a user'), false, 'frm_extensions_usermanPassword()'));
            $currentcomponent->addguielem($section, new gui_textbox_check('userman_username', '', _('Username'), _('If Create New User is selected this will be the username. If blank the username will be the same number as this device'), 'frm_extensions_usermanUsername()', _("Please select a valid username for New User Creation"), false, 0, true, _('Use Custom Username'), ""));
            $currentcomponent->addguielem($section, new gui_textbox('userman|password', md5(uniqid()), _('Password'), _('If Create New User is selected this will be the autogenerated users new password')));
        }
    } else {
        //unassign all extensions for this user
        foreach ($userman->getAllUsers() as $user) {
            $assigned = $userman->getGlobalSettingByID($user['id'], 'assigned');
            $assigned = array_diff($assigned, array($extdisplay));
            $userman->setGlobalSettingByID($user['id'], 'assigned', $assigned);
        }
    }
}
Esempio n. 23
0
 public function ucpConfigPage($mode, $user, $action)
 {
     if (empty($user)) {
         $enable = $mode == 'group' ? true : null;
         $download = $mode == 'group' ? true : null;
         $playback = $mode == 'group' ? true : null;
     } else {
         if ($mode == 'group') {
             $enable = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Cdr', 'enable');
             $download = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Cdr', 'download');
             $playback = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Cdr', 'playback');
             $cdrassigned = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Cdr', 'assigned');
         } else {
             $enable = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Cdr', 'enable');
             $download = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Cdr', 'download');
             $playback = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Cdr', 'playback');
             $cdrassigned = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Cdr', 'assigned');
         }
     }
     $cdrassigned = !empty($cdrassigned) ? $cdrassigned : array();
     $ausers = array();
     if ($action == "showgroup" || $action == "addgroup") {
         $ausers['self'] = _("User Primary Extension");
     }
     if ($action == "addgroup") {
         $cdrassigned = array('self');
     }
     foreach (core_users_list() as $list) {
         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
     }
     $html[0] = array("title" => _("Call History"), "rawname" => "cdrreports", "content" => load_view(dirname(__FILE__) . "/views/ucp_config.php", array("mode" => $mode, "enable" => $enable, "cdrassigned" => $cdrassigned, "ausers" => $ausers, "playback" => $playback, "download" => $download)));
     return $html;
 }
Esempio n. 24
0
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     $ast_ge_18 = version_compare($ast_version, '1.8', 'ge');
     $ast_ge_120 = version_compare($ast_version, '12', 'ge');
     // legacy but in case someone was using this we will leave it
     //TODO: abstract getters/setters from business logic
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if ($db->IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         if (empty($results2['context'])) {
             $results2['context'] = "";
         }
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         // Queues cannot control their own recordings, it must now be
         // done through sub-record-check
         unset($results2['monitor-format']);
         unset($results2['recording']);
         //Unset Old commands Resolves FREEPBX-8610.
         unset($results2['monitor-join']);
         unset($results2['answered_elsewhere']);
         unset($results2['skip_joinannounce']);
         //These items still exist for backwards compatibility but are useless in 12+
         if ($ast_ge_120) {
             unset($results2['eventwhencalled']);
             unset($results2['eventmemberstatus']);
         }
         foreach ($results2 as $keyword => $data) {
             if (trim($data) == '' && $keyword != "context" || substr($keyword, 0, 4) == "cron") {
                 // Skip anything that's empty or not required
                 continue;
             }
             // Some old commands have been removed. Make sure we
             // don't add them.
             switch ($keyword) {
                 case 'monitor-join':
                 case 'answered_elsewhere':
                 case 'skip_joinannounce':
                     continue;
                     break;
                 case 'music':
                     $keyword = 'musicclass';
                     break;
             }
             if ($keyword == "retry" && $data == "none") {
                 $data = 0;
             }
             $output .= $keyword . "=" . $data . "\n";
         }
         // Now pull out all the memebers, one line for each
         //
         if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = sprintf('"%s"', $users[$matches[1]]);
                     //str_replace(',','\,',$name);
                     $qnostate = queues_get_qnostate($matches[1]);
                     if ($qnostate == 'ignorestate') {
                         freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                         $output .= "member={$member},{$name}\n";
                     } else {
                         $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                     }
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = sprintf('"%s"', $users[$matches[1]]);
                         //str_replace(',','\,',$name);
                         $qnostate = queues_get_qnostate($matches[1]);
                         if ($qnostate == 'ignorestate') {
                             freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                             $output .= "member={$member},{$name}\n";
                         } else {
                             $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                         }
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         if (isset($this->_queues_additional[$result[0]])) {
             foreach ($this->_queues_additional[$result[0]] as $qsetting) {
                 $output .= $qsetting['key'] . "=" . $qsetting['value'] . "\n";
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _('Warning, there are compound recordings configured in ' . 'one or more Queue configurations. Queues can not play these ' . 'so they have been truncated to the first sound file. You ' . 'should correct this problem.<br />Details:<br /><br />');
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
Esempio n. 25
0
 /**
  * function generate_module_repo_url
  * short create array of full URLs to get a file from repo
  * use this function to generate an array of URLs for all configured REPOs
  * @author Philippe Lindheimer
  *
  * @pram string
  * @returns string
  */
 function generate_remote_urls($path, $add_options = false)
 {
     global $db;
     global $amp_conf;
     $urls = array();
     $options = array();
     if ($add_options) {
         $firstinstall = false;
         $type = null;
         $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
         $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
         // if not set so this is a first time install
         // get a new hash to account for first time install
         //
         $install_hash = $this->_generate_unique_id();
         $installid = $install_hash['uniqueid'];
         $type = $install_hash['type'];
         if (!isset($result['data']) || trim($result['data']) == "" || $installid != $result['data']) {
             //Yes they do the same thing but thats ok
             if (!isset($result['data']) || trim($result['data']) == "") {
                 $firstinstall = true;
                 $data4sql = $db->escapeSimple($installid);
                 sql("REPLACE INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
                 $data4sql = $db->escapeSimple($type);
                 sql("REPLACE INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
             } else {
                 $install_hash = $this->_regenerate_unique_id();
                 $installid = $install_hash['uniqueid'];
                 $type = $install_hash['type'];
             }
         } else {
             $installid = $result['data'];
             $sql = "SELECT * FROM module_xml WHERE id = 'type'";
             $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
             if (isset($result['data']) && trim($result['data']) != "") {
                 $type = $result['data'];
             }
         }
         // Now we have the id and know if this is a firstime install so we can get the announcement
         //
         $options['installid'] = $installid;
         if (trim($type) != "") {
             $options['type'] = trim($type);
         }
         if ($firstinstall) {
             $options['firstinstall'] = 'yes';
         }
         //Now that we do everything in post format send back module versions
         $modules_local = $this->getinfo(false, false, true);
         foreach ($modules_local as $m => $mod) {
             if ($mod['status'] != MODULE_STATUS_BROKEN) {
                 $options['modules'][$m]['version'] = $mod['version'];
                 $options['modules'][$m]['status'] = $mod['status'];
                 $options['modules'][$m]['rawname'] = $mod['rawname'];
                 $options['modules'][$m]['license'] = !empty($mod['license']) ? $mod['license'] : "unknown";
             }
         }
         // We check specifically for false because evenif blank it means the file
         // was there so we want module.xml to do appropriate actions
         $brandid = $this->_brandid();
         if ($brandid !== false) {
             $options['brandid'] = $brandid;
         }
         $deploymentid = $this->_deploymentid();
         if ($deploymentid !== false) {
             $options['deploymentid'] = $deploymentid;
         }
         $engver = engine_getinfo();
         if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
             $options['astver'] = $engver['version'];
         } else {
             $options['astver'] = $engver['raw'];
         }
         $options['phpver'] = phpversion();
         $distro_info = $this->_distro_id();
         $options['distro'] = $distro_info['pbx_type'];
         $options['distrover'] = $distro_info['pbx_version'];
         $options['pbxver'] = getversion();
         if (function_exists('core_users_list')) {
             $options['ucount'] = count(core_users_list());
         }
         // Other modules may need to add 'get' paramters to the call to the repo. Check and add them
         // here if we are adding paramters. The module should return an array of key/value pairs each of which
         // is to be appended to the GET parameters. The variable name will be prepended with the module name
         // when sent.
         //
         $repo_params = array();
         foreach (mod_func_iterator('module_repo_parameters_callback', $path) as $mod => $res) {
             if (is_array($res)) {
                 foreach ($res as $p => $v) {
                     $options[$mod . '_' . $p] = $v;
                 }
             }
         }
     }
     $repos = explode(',', $amp_conf['MODULE_REPO']);
     return array('mirrors' => $repos, 'path' => $path, 'options' => $options, 'query' => http_build_query($options));
 }
 public function ucpConfigPage($mode, $user, $action)
 {
     if (empty($user)) {
         $enable = $mode == 'group' ? true : null;
         $playback = $mode == 'group' ? true : null;
         $download = $mode == 'group' ? true : null;
         $settings = $mode == 'group' ? true : null;
         $greetings = $mode == 'group' ? true : null;
         $vmxlocater = $mode == 'group' ? true : null;
     } else {
         if ($mode == "group") {
             $vmassigned = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'assigned');
             $enable = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'enable');
             $enable = !$enable ? false : true;
             $vmassigned = !empty($vmassigned) ? $vmassigned : array('self');
             $playback = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'playback');
             $playback = !$playback ? false : true;
             $download = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'download');
             $download = !$download ? false : true;
             $settings = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'settings');
             $settings = !$settings ? false : true;
             $greetings = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'greetings');
             $greetings = !$greetings ? false : true;
             $vmxlocater = $this->FreePBX->Ucp->getSettingByGID($user['id'], 'Voicemail', 'vmxlocater');
             $vmxlocater = !$vmxlocater ? false : true;
         } else {
             $vmassigned = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'assigned');
             $enable = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'enable');
             $playback = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'playback');
             $download = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'download');
             $settings = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'settings');
             $greetings = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'greetings');
             $vmxlocater = $this->FreePBX->Ucp->getSettingByID($user['id'], 'Voicemail', 'vmxlocater');
         }
     }
     $vmassigned = !empty($vmassigned) ? $vmassigned : array();
     $ausers = array();
     if ($action == "showgroup" || $action == "addgroup") {
         $ausers['self'] = _("User Primary Extension");
     }
     if ($action == "addgroup") {
         $vmassigned = array('self');
     }
     foreach (core_users_list() as $list) {
         $cul[$list[0]] = array("name" => $list[1], "vmcontext" => $list[2]);
         $ausers[$list[0]] = $list[1] . " &#60;" . $list[0] . "&#62;";
     }
     $html[0] = array("title" => _("Voicemail"), "rawname" => "voicemail", "content" => load_view(dirname(__FILE__) . "/views/ucp_config.php", array("vmxlocater" => $vmxlocater, "playback" => $playback, "download" => $download, "settings" => $settings, "greetings" => $greetings, "mode" => $mode, "enable" => $enable, "ausers" => $ausers, "vmassigned" => $vmassigned)));
     return $html;
 }