Rename user_uuid device_user_uuid in the devices table. Add an apply button to the key dashboard and provision button to the device edit.
This commit is contained in:
parent
704cf23194
commit
e5020a842b
|
|
@ -258,7 +258,8 @@
|
|||
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = "device_user_uuid";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['name']['deprecated'] = "user_uuid";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
/*
|
||||
FusionPBX
|
||||
Version: MPL 1.1
|
||||
|
||||
The contents of this file are subject to the Mozilla Public License Version
|
||||
1.1 (the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS" basis,
|
||||
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
for the specific language governing rights and limitations under the
|
||||
License.
|
||||
|
||||
The Original Code is FusionPBX
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2008-2014
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
*/
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
if (permission_exists("device_key_add") || permission_exists("device_key_edit") || if_group("superadmin")) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//set the variables
|
||||
$cmd = check_str($_GET['cmd']);
|
||||
$rdr = check_str($_GET['rdr']);
|
||||
$profile = check_str($_GET['profile']);
|
||||
$domain = check_str($_GET['domain']);
|
||||
$show = check_str($_GET['show']);
|
||||
$user = check_str($_GET['user']);
|
||||
$agent = check_str($_GET['agent']);
|
||||
|
||||
//get the vendor
|
||||
if (preg_replace('/^.*?(aastra).*$/i', '$1', strtolower($agent)) == "aastra") {
|
||||
$vendor = "aastra";
|
||||
}
|
||||
if (preg_replace('/^.*?(cisco).*$/i', '$1', strtolower($agent)) == "cisco") {
|
||||
$vendor = "cisco";
|
||||
}
|
||||
if (preg_replace('/^.*?(cisco\/spa).*$/i', '$1', strtolower($agent)) == "cisco/spa") {
|
||||
$vendor = "cisco-spa";
|
||||
}
|
||||
if (preg_replace('/^.*?(grandstream).*$/i', '$1', strtolower($agent)) == "grandstream") {
|
||||
$vendor = "grandstream";
|
||||
}
|
||||
if (preg_replace('/^.*?(linksys).*$/i', '$1', strtolower($agent)) == "linksys") {
|
||||
$vendor = "linksys";
|
||||
}
|
||||
if (preg_replace('/^.*?(polycom).*$/i', '$1', strtolower($agent)) == "polycom") {
|
||||
$vendor = "polycom";
|
||||
}
|
||||
if (preg_replace('/^.*?(yealink).*$/i', '$1', strtolower($agent)) == "yealink") {
|
||||
$vendor = "yealink";
|
||||
}
|
||||
if (preg_replace('/^.*?(vp530p).*$/i', '$1', strtolower($agent)) == "vp530p") {
|
||||
$vendor = "yealink";
|
||||
}
|
||||
if (preg_replace('/^.*?(snom).*$/i', '$1', strtolower($agent)) == "snom") {
|
||||
$vendor = "snom";
|
||||
}
|
||||
|
||||
//create the event socket connection
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
//prepare the command
|
||||
if ($cmd == "unregister") {
|
||||
$command = "sofia profile ".$profile." flush_inbound_reg ".$user." reboot";
|
||||
}
|
||||
else {
|
||||
$command = "lua app.lua event_notify ".$profile." ".$cmd." ".$user." ".$vendor;
|
||||
|
||||
//if ($cmd == "check_sync") {
|
||||
// $command = "sofia profile ".$profile." check_sync ".$user;
|
||||
//}
|
||||
}
|
||||
//send the command
|
||||
$response = event_socket_request($fp, "api ".$command);
|
||||
$response = event_socket_request($fp, "api log notice ".$command);
|
||||
//show the response
|
||||
$_SESSION['message'] = $text['label-event']." ".ucwords($cmd)." ".$text['label-response'].$response;
|
||||
//close the connection
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
if ($rdr == "false") {
|
||||
//redirect false
|
||||
echo $response;
|
||||
}
|
||||
else {
|
||||
header("Location: status_registrations.php?profile=".$profile."&show=".$show);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -232,6 +232,10 @@
|
|||
echo " <br />";
|
||||
echo " </div>\n";
|
||||
|
||||
echo " <div style='float: right;'>";
|
||||
echo " <input type='button' class='btn' value='".$text['button-apply']."' onclick=\"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&show=".$show."&user=".$row['user']."&domain=".$row['sip-auth-realm']."&agent=".urlencode($row['agent'])."';\" ".$onhover_pause_refresh.">\n";
|
||||
echo " </div>\n";
|
||||
|
||||
echo "<div style='float: right;'>\n";
|
||||
echo " <input type='submit' class='btn' value='".$text['button-save']."'>";
|
||||
echo "</div>\n";
|
||||
|
|
|
|||
|
|
@ -632,6 +632,8 @@ require_once "resources/require.php";
|
|||
echo " </select>\n";
|
||||
//echo " <input type='button' class='btn' id='button_download' style='display: none;' alt='".$text['button-download']."' value='".$text['button-download']."' onclick='document.forms.frm.submit();'>";
|
||||
}
|
||||
echo " <input type='button' class='btn' alt='".$text['button-provision']."' value='".$text['button-provision']."' onclick=\"document.location.href='".PROJECT_PATH."/app/devices/cmd.php?cmd=check_sync&profile=".$sip_profile_name."&show=".$show."&user=".$row['user']."&domain=".$row['sip-auth-realm']."&agent=".urlencode($row['agent'])."';\" ".$onhover_pause_refresh.">\n";
|
||||
|
||||
if (permission_exists('device_add') && $action != "add") {
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"var new_mac = prompt('".$text['message_device']."'); if (new_mac != null) { window.location='device_copy.php?id=".$device_uuid."&mac=' + new_mac; }\" value='".$text['button-copy']."'>\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ include "root.php";
|
|||
}
|
||||
}
|
||||
|
||||
private function contact_append(&$contacts, &$line, $domain_uuid, $user_uuid, $is_group){
|
||||
private function contact_append(&$contacts, &$line, $domain_uuid, $device_user_uuid, $is_group){
|
||||
$sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, ";
|
||||
$sql .= "c.contact_type, c.contact_category, p.phone_label,";
|
||||
$sql .= "p.phone_number, p.phone_extension, p.phone_primary ";
|
||||
|
|
@ -177,14 +177,14 @@ include "root.php";
|
|||
$sql .= " select contact_uuid from v_contact_groups ";
|
||||
$sql .= " where group_uuid in ( ";
|
||||
$sql .= " select group_uuid from v_group_users ";
|
||||
$sql .= " where user_uuid = '$user_uuid' ";
|
||||
$sql .= " where user_uuid = '$device_user_uuid' ";
|
||||
$sql .= " and domain_uuid = '$domain_uuid' ";
|
||||
$sql .= " )) ";
|
||||
}
|
||||
else {
|
||||
$sql .= "and c.contact_uuid in ( ";
|
||||
$sql .= " select contact_uuid from v_contact_users ";
|
||||
$sql .= " where user_uuid = '$user_uuid' ";
|
||||
$sql .= " where user_uuid = '$device_user_uuid' ";
|
||||
$sql .= " and domain_uuid = '$domain_uuid' ";
|
||||
$sql .= ") ";
|
||||
}
|
||||
|
|
@ -245,25 +245,6 @@ include "root.php";
|
|||
unset($temp_contacts);
|
||||
}
|
||||
|
||||
private function user_uuid_for_line(&$line, $domain_uuid){
|
||||
$sql = "select user_uuid from v_extension_users ";
|
||||
$sql .= "where extension_uuid in ( ";
|
||||
$sql .= " select extension_uuid from v_extensions ";
|
||||
$sql .= " where (extension = '".$line["user_id"]."' or number_alias = '".$line["user_id"]."') ";
|
||||
$sql .= " and domain_uuid = '$domain_uuid' ";
|
||||
$sql .= ") ";
|
||||
$sql .= "and domain_uuid = '$domain_uuid' ";
|
||||
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$extension_users = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
unset($prep_statement, $sql);
|
||||
foreach ($extension_users as &$row) {
|
||||
return $row["user_uuid"];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function render() {
|
||||
|
||||
//debug
|
||||
|
|
@ -340,6 +321,7 @@ include "root.php";
|
|||
if (strlen($row["device_vendor"]) > 0) {
|
||||
$device_vendor = strtolower($row["device_vendor"]);
|
||||
}
|
||||
$device_user_uuid = $row["device_user_uuid"];
|
||||
$device_model = $row["device_model"];
|
||||
$device_firmware_version = $row["device_firmware_version"];
|
||||
$device_enabled = $row["device_enabled"];
|
||||
|
|
@ -476,6 +458,7 @@ include "root.php";
|
|||
$row = $prep_statement_4->fetch();
|
||||
$device_label = $row["device_label"];
|
||||
$device_firmware_version = $row["device_firmware_version"];
|
||||
$device_user_uuid = $row["device_user_uuid"];
|
||||
$device_enabled = $row["device_enabled"];
|
||||
//keep the original template
|
||||
$device_profile_uuid = $row["device_profile_uuid"];
|
||||
|
|
@ -580,22 +563,15 @@ include "root.php";
|
|||
//get the list of contact directly assigned to the user
|
||||
//get the user_uuid to find the contacts assigned to the user and the groups the user is a member of.
|
||||
if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0) {
|
||||
if ($_SESSION['provision']['contact_users']['boolean'] == "true" || $_SESSION['provision']['contact_groups']['boolean'] == "true") {
|
||||
foreach ($device_lines as &$line) {
|
||||
$user_uuid = $this->user_uuid_for_line($line, $domain_uuid);
|
||||
if(!$user_uuid) continue;
|
||||
//get the contacts assigned to the groups and add to the contacts array
|
||||
if ($_SESSION['provision']['contact_groups']['boolean'] == "true") {
|
||||
$this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, true);
|
||||
}
|
||||
|
||||
//get the contacts assigned to the groups and add to the contacts array
|
||||
if ($_SESSION['provision']['contact_groups']['boolean'] == "true") {
|
||||
$this->contact_append($contacts, $line, $domain_uuid, $user_uuid, true);
|
||||
}
|
||||
|
||||
//get the contacts assigned to the user and add to the contacts array
|
||||
if ($_SESSION['provision']['contact_users']['boolean'] == "true") {
|
||||
$this->contact_append($contacts, $line, $domain_uuid, $user_uuid, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
//get the contacts assigned to the user and add to the contacts array
|
||||
if ($_SESSION['provision']['contact_users']['boolean'] == "true") {
|
||||
$this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, false);
|
||||
}
|
||||
}
|
||||
|
||||
//get the extensions and add them to the contacts array
|
||||
|
|
|
|||
|
|
@ -161,6 +161,20 @@ $text['confirm-copy']['de-at'] = "Wollen Sie das wirklich kopieren?";
|
|||
|
||||
//buttons
|
||||
|
||||
$text['button-apply']['en-us'] = "Apply";
|
||||
$text['button-apply']['es-cl'] = "";
|
||||
$text['button-apply']['pt-pt'] = "";
|
||||
$text['button-apply']['fr-fr'] = "";
|
||||
$text['button-apply']['pt-br'] = "";
|
||||
$text['button-apply']['pl'] = "";
|
||||
$text['button-apply']['he'] = "";
|
||||
$text['button-apply']['uk'] = "";
|
||||
$text['button-apply']['sv-se'] = "";
|
||||
$text['button-apply']['de-at'] = "";
|
||||
$text['button-apply']['ro'] = "";
|
||||
$text['button-apply']['fa'] = "";
|
||||
$text['button-apply']['ar-eg'] = "";
|
||||
|
||||
$text['button-clear']['en-us'] = "Clear";
|
||||
$text['button-clear']['es-cl'] = "Limpiar";
|
||||
$text['button-clear']['pt-pt'] = "Apagar";
|
||||
|
|
|
|||
Loading…
Reference in New Issue