GS Wave: Restrict users to assigned extensions.

This commit is contained in:
Nate
2019-11-02 20:50:35 -06:00
parent 04ed446f64
commit b986fa0415

View File

@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2018
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -47,55 +47,62 @@
$extension_uuid = $_GET['id'];
}
//get the extensions
$sql = "select * from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and enabled = 'true' ";
$sql .= "order by extension asc ";
//get the extension(s)
$sql = "select e.* ";
$sql .= "from v_extensions as e, ";
$sql .= "v_extension_users as eu ";
$sql .= "where e.extension_uuid = eu.extension_uuid ";
if (!permission_exists('extension_edit')) {
$sql .= "and eu.user_uuid = :user_uuid ";
$parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
}
$sql .= "and e.domain_uuid = :domain_uuid ";
$sql .= "and e.enabled = 'true' ";
$sql .= "group by e.extension_uuid ";
$sql .= "order by e.extension asc ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$database = new database;
$extensions = $database->select($sql, $parameters, 'all');
unset($sql, $parameters);
//get the extension
if (is_uuid($_GET['id'])) {
$sql = "select * from v_extensions ";
$sql .= "where domain_uuid = :domain_uuid ";
$sql .= "and extension_uuid = :extension_uuid ";
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$parameters['extension_uuid'] = $extension_uuid;
$database = new database;
$extension = $database->select($sql, $parameters, 'all');
$field = $extension[0];
unset($sql, $parameters);
}
if (is_uuid($extension_uuid) && is_array($extensions) && @sizeof($extensions) != 0) {
//get the username
$username = $field['extension'];
if (isset($field['number_alias']) && strlen($field['number_alias']) > 0) {
$username = $field['number_alias'];
}
//loop through get selected extension
if (is_array($extensions) && @sizeof($extensions) != 0) {
foreach ($extensions as $extension) {
if ($extension['extension_uuid'] == $extension_uuid) {
$field = $extension;
break;
}
}
}
//get the username
$username = $field['extension'];
if (isset($field['number_alias']) && strlen($field['number_alias']) > 0) {
$username = $field['number_alias'];
}
//build the xml
$xml = "<?xml version='1.0' encoding='utf-8'?>";
$xml .= "<AccountConfig version='1'>";
$xml .= "<Account>";
$xml .= "<RegisterServer>".$_SESSION['domain_name']."</RegisterServer>";
//$xml .= "<OutboundServer>".$_SESSION['domain_name']."</OutboundServer>";
//$xml .= "<SecOutboundServer>".$_SESSION['domain_name']."</SecOutboundServer>";
$xml .= "<OutboundServer>".$_SESSION['domain_name'].":".$_SESSION['provision']['line_sip_port']['numeric']."</OutboundServer>";
$xml .= "<SecOutboundServer>".$_SESSION['domain_name'].":".$_SESSION['provision']['line_sip_port']['numeric']."</SecOutboundServer>";
$xml .= "<UserID>".$username."</UserID>";
$xml .= "<AuthID>".$username."</AuthID>";
$xml .= "<AuthPass>".$field['password']."</AuthPass>";
$xml .= "<AccountName>".$username."</AccountName>";
$xml .= "<DisplayName>".$username."</DisplayName>";
$xml .= "<Dialplan>{x+|*x+|*++}</Dialplan>";
$xml .= "<RandomPort>0</RandomPort>";
$xml .= "<Voicemail>*97</Voicemail>";
$xml .= "</Account>";
$xml .= "</AccountConfig>";
//build the xml
if (is_uuid($_GET['id'])) {
$xml = "<?xml version='1.0' encoding='utf-8'?>";
$xml .= "<AccountConfig version='1'>";
$xml .= "<Account>";
$xml .= "<RegisterServer>".$_SESSION['domain_name']."</RegisterServer>";
//$xml .= "<OutboundServer>".$_SESSION['domain_name']."</OutboundServer>";
//$xml .= "<SecOutboundServer>".$_SESSION['domain_name']."</SecOutboundServer>";
$xml .= "<OutboundServer>".$_SESSION['domain_name'].":".$_SESSION['provision']['line_sip_port']['numeric']."</OutboundServer>";
$xml .= "<SecOutboundServer>".$_SESSION['domain_name'].":".$_SESSION['provision']['line_sip_port']['numeric']."</SecOutboundServer>";
$xml .= "<UserID>".$username."</UserID>";
$xml .= "<AuthID>".$username."</AuthID>";
$xml .= "<AuthPass>".$field['password']."</AuthPass>";
$xml .= "<AccountName>".$username."</AccountName>";
$xml .= "<DisplayName>".$username."</DisplayName>";
$xml .= "<Dialplan>{x+|*x+|*++}</Dialplan>";
$xml .= "<RandomPort>0</RandomPort>";
$xml .= "<Voicemail>*97</Voicemail>";
$xml .= "</Account>";
$xml .= "</AccountConfig>";
}
//debian
@@ -136,9 +143,11 @@
echo "<td class='vtable' style='position: relative;' align='left'>\n";
echo " <select class='formfld' onchange='this.form.submit();' name='id'>\n";
echo " <option value=''></option>\n";
foreach($extensions as $row) {
if ($row['extension_uuid'] == $extension_uuid) { $selected = "selected='selected'"; } else { $selected = ''; }
echo " <option value='".escape($row['extension_uuid'])."' $selected>".escape($row['extension'])." ".escape($row['number_alias'])." ".escape($row['description'])."</option>\n";
if (is_array($extensions) && @sizeof($extensions) != 0) {
foreach($extensions as $row) {
$selected = $row['extension_uuid'] == $extension_uuid ? "selected='selected'" : null;
echo " <option value='".escape($row['extension_uuid'])."' ".$selected.">".escape($row['extension'])." ".escape($row['number_alias'])." ".escape($row['description'])."</option>\n";
}
}
echo " </select>\n";
//echo "<br />\n";
@@ -160,7 +169,7 @@
echo "<br />";
//stream the file
if (is_uuid($_GET['id'])) {
if (is_uuid($extension_uuid)) {
$include_path = get_include_path();
$xml = html_entity_decode( $xml, ENT_QUOTES, 'UTF-8' );
set_include_path ($_SERVER["PROJECT_ROOT"].'/resources/qr_code');
@@ -191,7 +200,7 @@
}
//html image
if (is_uuid($_GET['id'])) {
if (is_uuid($extension_uuid)) {
echo "<img src=\"data:image/jpeg;base64,". base64_encode($image) ."\">\n";
}
@@ -199,4 +208,4 @@
set_include_path ($include_path);
require_once "resources/footer.php";
?>
?>