Add device key extension for yealink. Add a device class.

This commit is contained in:
Mark Crane
2014-01-03 23:11:42 +00:00
parent b2e1017294
commit 13025158fd
5 changed files with 161 additions and 36 deletions

View File

@@ -253,6 +253,12 @@
$text['description-device_key_value']['en-us'] = 'Enter the value.';
$text['description-device_key_value']['pt-pt'] = '';
$text['label-device_key_extension']['en-us'] = 'Extension';
$text['label-device_key_extension']['pt-pt'] = '';
$text['description-device_key_extension']['en-us'] = 'Enter the extension.';
$text['description-device_key_extension']['pt-pt'] = '';
$text['label-device_key_label']['en-us'] = 'Label';
$text['label-device_key_label']['pt-pt'] = '';

View File

@@ -41,6 +41,9 @@ require_once "resources/require.php";
$text[$key] = $value[$_SESSION['domain']['language']['code']];
}
//include the device class
require_once "app/devices/resources/classes/device.php";
//action add or update
if (isset($_REQUEST["id"])) {
$action = "update";
@@ -80,6 +83,7 @@ require_once "resources/require.php";
$device_key_type = check_str($_POST["device_key_type"]);
$device_key_line = check_str($_POST["device_key_line"]);
$device_key_value = check_str($_POST["device_key_value"]);
$device_key_extension = check_str($_POST["device_key_extension"]);
$device_key_label = check_str($_POST["device_key_label"]);
//settings
//$device_setting_category = check_str($_POST["device_setting_category"]);
@@ -90,38 +94,9 @@ require_once "resources/require.php";
$device_setting_description = check_str($_POST["device_setting_description"]);
}
//use the mac address to find the vendor
//use the mac address to get the vendor
if (strlen($device_vendor) == 0) {
switch (substr($device_mac_address, 0, 6)) {
case "00085d":
$device_vendor = "aastra";
break;
case "000e08":
$device_vendor = "linksys";
break;
case "0004f2":
$device_vendor = "polycom";
break;
case "00907a":
$device_vendor = "polycom";
break;
case "001873":
$device_vendor = "cisco";
break;
case "00045a":
$device_vendor = "linksys";
break;
case "000625":
$device_vendor = "linksys";
break;
case "001565":
$device_vendor = "yealink";
break;
case "000413":
$device_vendor = "snom";
default:
$device_vendor = "";
}
$device_vendor = device::get_vendor($device_mac_address);
}
//add or update the database
@@ -264,6 +239,7 @@ require_once "resources/require.php";
$sql .= "device_key_type, ";
$sql .= "device_key_line, ";
$sql .= "device_key_value, ";
$sql .= "device_key_extension, ";
$sql .= "device_key_label ";
$sql .= ")";
$sql .= " values ";
@@ -276,6 +252,7 @@ require_once "resources/require.php";
$sql .= "'$device_key_type', ";
$sql .= "'$device_key_line', ";
$sql .= "'$device_key_value', ";
$sql .= "'$device_key_extension', ";
$sql .= "'$device_key_label' ";
$sql .= ")";
$db->exec(check_sql($sql));
@@ -329,7 +306,7 @@ require_once "resources/require.php";
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$device_uuid = check_str($_GET["id"]);
$sql = "select * from v_devices ";
$sql .= "where domain_uuid = '$domain_uuid' ";
@@ -354,6 +331,11 @@ require_once "resources/require.php";
unset ($prep_statement);
}
//use the mac address to get the vendor
if (strlen($device_vendor) == 0) {
$device_vendor = device::get_vendor($device_mac_address);
}
//show the header
require_once "resources/header.php";
@@ -565,6 +547,7 @@ require_once "resources/require.php";
echo " <td class='vtable'>".$text['label-device_key_type']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_line']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_value']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_extension']."</td>\n";
echo " <td class='vtable'>".$text['label-device_key_label']."</td>\n";
echo " <td>&nbsp;</td>\n";
echo " </tr>\n";
@@ -600,6 +583,9 @@ require_once "resources/require.php";
echo " ".$row['device_key_value']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_key_extension']."&nbsp;\n";
echo " </td>\n";
echo " <td class='vtable'>\n";
echo " ".$row['device_key_label']."&nbsp;\n";
echo " </td>\n";
echo " <td>\n";
@@ -758,6 +744,10 @@ require_once "resources/require.php";
echo " <input class='formfld' type='text' name='device_key_value' style='width: 120px;' maxlength='255' value=\"$device_key_value\">\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_key_extension' style='width: 120px;' maxlength='255' value=\"$device_key_extension\">\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_key_label' style='width: 150px;' maxlength='255' value=\"$device_key_label\">\n";
echo "</td>\n";

View File

@@ -61,6 +61,7 @@ else {
$device_key_type = check_str($_POST["device_key_type"]);
$device_key_line = check_str($_POST["device_key_line"]);
$device_key_value = check_str($_POST["device_key_value"]);
$device_key_extension = check_str($_POST["device_key_extension"]);
$device_key_label = check_str($_POST["device_key_label"]);
}
@@ -77,6 +78,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//if (strlen($device_key_type) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_type']."<br>\n"; }
//if (strlen($device_key_line) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_line']."<br>\n"; }
//if (strlen($device_key_value) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_value']."<br>\n"; }
//if (strlen($device_key_extension) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_extension']."<br>\n"; }
//if (strlen($device_key_label) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_label']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
@@ -104,6 +106,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "device_key_type, ";
$sql .= "device_key_line, ";
$sql .= "device_key_value, ";
$sql .= "device_key_extension, ";
$sql .= "device_key_label ";
$sql .= ")";
$sql .= "values ";
@@ -115,6 +118,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "'$device_key_category', ";
$sql .= "'$device_key_type', ";
$sql .= "'$device_key_line', ";
$sql .= "'$device_key_value', ";
$sql .= "'$device_key_extension', ";
$sql .= "'$device_key_label' ";
$sql .= ")";
$db->exec(check_sql($sql));
@@ -136,6 +141,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql .= "device_key_type = '$device_key_type', ";
$sql .= "device_key_line = '$device_key_line', ";
$sql .= "device_key_value = '$device_key_value', ";
$sql .= "device_key_extension = '$device_key_extension', ";
$sql .= "device_key_label = '$device_key_label' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and device_key_uuid = '$device_key_uuid' ";
@@ -168,6 +174,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$device_key_type = $row["device_key_type"];
$device_key_line = $row["device_key_line"];
$device_key_value = $row["device_key_value"];
$device_key_extension = $row["device_key_extension"];
$device_key_label = $row["device_key_label"];
}
unset ($prep_statement);
@@ -531,6 +538,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_key_extension'].":\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='device_key_extension' maxlength='255' value=\"$device_key_extension\">\n";
echo "<br />\n";
echo $text['description-device_key_extension']."\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-device_key_label'].":\n";

View File

@@ -112,8 +112,8 @@ else {
//echo th_order_by('device_uuid', $text['label-device_uuid'], $order_by, $order);
echo th_order_by('device_mac_address', $text['label-device_mac_address'], $order_by, $order);
echo th_order_by('device_label', $text['label-device_label'], $order_by, $order);
//echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order);
echo th_order_by('device_model', $text['label-device_model'], $order_by, $order);
echo th_order_by('device_vendor', $text['label-device_vendor'], $order_by, $order);
//echo th_order_by('device_model', $text['label-device_model'], $order_by, $order);
//echo th_order_by('device_firmware_version', $text['label-device_firmware_version'], $order_by, $order);
echo th_order_by('device_provision_enable', $text['label-device_provision_enable'], $order_by, $order);
echo th_order_by('device_template', $text['label-device_template'], $order_by, $order);
@@ -140,8 +140,8 @@ else {
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_uuid']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_mac_address']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_label']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_vendor']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_model']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_vendor']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_model']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_firmware_version']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_provision_enable']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['device_template']."&nbsp;</td>\n";

View File

@@ -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>
Copyright (C) 2010
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
//define the device class
class device {
public $db;
public $domain_uuid;
public function __construct() {
//require_once "resources/classes/database.php";
}
public function __destruct() {
foreach ($this as $key => $value) {
unset($this->$key);
}
}
public function get_domain_uuid() {
return $this->domain_uuid;
}
public function get_vendor($mac){
//use the mac address to find the vendor
$mac = preg_replace('#[^a-fA-F0-9./]#', '', $mac);
$mac = strtolower($mac);
switch (substr($mac, 0, 6)) {
case "00085d":
$device_vendor = "aastra";
break;
case "000e08":
$device_vendor = "linksys";
break;
case "0004f2":
$device_vendor = "polycom";
break;
case "00907a":
$device_vendor = "polycom";
break;
case "0080f0":
$device_vendor = "panasonic";
break;
case "001873":
$device_vendor = "cisco";
break;
case "a44c11":
$device_vendor = "cisco";
break;
case "0021A0":
$device_vendor = "cisco";
break;
case "30e4db":
$device_vendor = "cisco";
break;
case "002155":
$device_vendor = "cisco";
break;
case "68efbd":
$device_vendor = "cisco";
break;
case "00045a":
$device_vendor = "linksys";
break;
case "000625":
$device_vendor = "linksys";
break;
case "001565":
$device_vendor = "yealink";
break;
case "000413":
$device_vendor = "snom";
break;
case "000b82":
$device_vendor = "grandstream";
break;
case "00177d":
$device_vendor = "konftel";
break;
default:
$device_vendor = "";
}
return $device_vendor;
}
}
?>