mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Add device copy to make it faster to add devices for endpoint provisioning.
This commit is contained in:
@@ -644,6 +644,26 @@
|
||||
$text['button-view']['pt-pt'] = "Vista";
|
||||
$text['button-view']['fr-fr'] = "Voir";
|
||||
|
||||
$text['button-copy']['en-us'] = "Copy";
|
||||
$text['button-copy']['es-cl'] = "Copiar";
|
||||
$text['button-copy']['pt-pt'] = "Copiar";
|
||||
$text['button-copy']['fr-fr'] = "Copier";
|
||||
|
||||
$text['confirm-copy']['en-us'] = "Do you really want to copy this?";
|
||||
$text['confirm-copy']['es-cl'] = "¿Realmente desea copiar esto?";
|
||||
$text['confirm-copy']['pt-pt'] = "Deseja realmente copiar isto?";
|
||||
$text['confirm-copy']['fr-fr'] = "Voulez-vous vraiment copier cela?";
|
||||
|
||||
$text['message-copy']['en-us'] = "Copy Completed";
|
||||
$text['message-copy']['es-cl'] = "Copia Completada";
|
||||
$text['message-copy']['pt-pt'] = "Cópia Efectuada";
|
||||
$text['message-copy']['fr-fr'] = "Copié";
|
||||
|
||||
$text['message_device']['en-us'] = "Enter the new MAC Address.";
|
||||
$text['message_device']['es-cl'] = "Introduzca la nueva dirección MAC.";
|
||||
$text['message_device']['pt-pt'] = "Digite o novo endereço MAC.";
|
||||
$text['message_device']['fr-fr'] = "Insérer la nouvelle adresse MAC.";
|
||||
|
||||
$text['button-back']['en-us'] = "Back";
|
||||
$text['button-back']['es-cl'] = "Volver";
|
||||
$text['button-back']['pt-pt'] = "Voltar";
|
||||
|
||||
137
app/devices/device_copy.php
Normal file
137
app/devices/device_copy.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<?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-2012
|
||||
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_add')) {
|
||||
//access granted
|
||||
}
|
||||
else {
|
||||
echo "access denied";
|
||||
exit;
|
||||
}
|
||||
|
||||
//add multi-lingual support
|
||||
require_once "app_languages.php";
|
||||
foreach($text as $key => $value) {
|
||||
$text[$key] = $value[$_SESSION['domain']['language']['code']];
|
||||
}
|
||||
|
||||
//set the http get/post variable(s) to a php variable
|
||||
if (isset($_REQUEST["id"]) && isset($_REQUEST["mac"])) {
|
||||
$device_uuid = check_str($_REQUEST["id"]);
|
||||
$mac_address_new = check_str($_REQUEST["mac"]);
|
||||
$mac_address_new = preg_replace('#[^a-fA-F0-9./]#', '', $mac_address_new);
|
||||
}
|
||||
|
||||
//get the device
|
||||
$sql = "SELECT * FROM v_devices ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and device_uuid = '".$device_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$devices = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//get device lines
|
||||
$sql = "SELECT * FROM v_device_lines ";
|
||||
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "and device_uuid = '".$device_uuid."' ";
|
||||
$sql .= "order by line_number asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//get device keys
|
||||
$sql = "SELECT * FROM v_device_keys ";
|
||||
$sql .= "WHERE domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "AND device_uuid = '".$device_uuid."' ";
|
||||
$sql .= "ORDER by ";
|
||||
$sql .= "CASE device_key_category ";
|
||||
$sql .= "WHEN 'line' THEN 1 ";
|
||||
$sql .= "WHEN 'memort' THEN 2 ";
|
||||
$sql .= "WHEN 'programmable' THEN 3 ";
|
||||
$sql .= "WHEN 'expansion' THEN 4 ";
|
||||
$sql .= "ELSE 100 END, ";
|
||||
$sql .= "cast(device_key_id as numeric) asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//get device settings
|
||||
$sql = "SELECT * FROM v_device_settings ";
|
||||
$sql .= "WHERE domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "AND device_uuid = '".$device_uuid."' ";
|
||||
$sql .= "ORDER by device_setting_subcategory asc ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
|
||||
//prepare the devices array
|
||||
unset($devices[0]["device_uuid"]);
|
||||
|
||||
//prepare the device_lines array
|
||||
$x = 0;
|
||||
foreach ($device_lines as $row) {
|
||||
unset($device_lines[$x]["device_uuid"]);
|
||||
unset($device_lines[$x]["device_line_uuid"]);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//prepare the device_keys array
|
||||
$x = 0;
|
||||
foreach ($device_keys as $row) {
|
||||
unset($device_keys[$x]["device_uuid"]);
|
||||
unset($device_keys[$x]["device_key_uuid"]);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//prepare the device_settings array
|
||||
$x = 0;
|
||||
foreach ($device_settings as $row) {
|
||||
unset($device_settings[$x]["device_uuid"]);
|
||||
unset($device_settings[$x]["device_setting_uuid"]);
|
||||
$x++;
|
||||
}
|
||||
|
||||
//create the device array
|
||||
$device = $devices[0];
|
||||
$device["device_mac_address"] = $mac_address_new;
|
||||
$device["device_lines"] = $device_lines;
|
||||
$device["device_keys"] = $device_keys;
|
||||
$device["device_settings"] = $device_settings;
|
||||
|
||||
//copy the device
|
||||
$orm = new orm;
|
||||
$orm->name('devices');
|
||||
$orm->save($device);
|
||||
$response = $orm->message;
|
||||
|
||||
//redirect
|
||||
$_SESSION["message"] = $text['message-copy'];
|
||||
header("Location: devices.php");
|
||||
return;
|
||||
|
||||
?>
|
||||
@@ -385,6 +385,9 @@ require_once "resources/require.php";
|
||||
echo "<td align='left' width='30%' nowrap='nowrap'><b>".$text['header-device']."</b></td>\n";
|
||||
echo "<td width='70%' align='right'>\n";
|
||||
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
||||
if ($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";
|
||||
}
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='devices.php'\" value='".$text['button-back']."'>\n";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
Reference in New Issue
Block a user