Device profile settings (#2165)
* Update app_config.php * Update device_profile_edit.php * Update device_setting_delete.php * Update provision.php
This commit is contained in:
parent
2c7715dcfd
commit
a7b76b7a84
|
|
@ -503,6 +503,15 @@
|
|||
$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'] = "device_profile_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)";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_device_profiles";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "device_profile_uuid";
|
||||
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
|
||||
$z++;
|
||||
|
||||
$y = 3; //table array index
|
||||
$z = 0; //field array index
|
||||
|
|
|
|||
|
|
@ -63,7 +63,14 @@
|
|||
$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"]);
|
||||
|
||||
|
||||
//$device_setting_category = check_str($_POST["device_setting_category"]);
|
||||
$device_setting_subcategory = check_str($_POST["device_setting_subcategory"]);
|
||||
//$device_setting_name = check_str($_POST["device_setting_name"]);
|
||||
$device_setting_value = check_str($_POST["device_setting_value"]);
|
||||
$device_setting_enabled = check_str($_POST["device_setting_enabled"]);
|
||||
$device_setting_description = check_str($_POST["device_setting_description"]);
|
||||
|
||||
//allow the domain_uuid to be changed only with the device_profile_domain permission
|
||||
if (permission_exists('device_profile_domain')) {
|
||||
$domain_uuid = check_str($_POST["domain_uuid"]);
|
||||
|
|
@ -122,6 +129,21 @@
|
|||
$x++;
|
||||
}
|
||||
|
||||
$x = 0;
|
||||
foreach ($_POST["device_settings"] as $row) {
|
||||
//unset the empty row
|
||||
if (strlen($row["device_setting_subcategory"]) == 0) {
|
||||
unset($_POST["device_settings"][$x]);
|
||||
}
|
||||
//unset device_detail_uuid if the field has no value
|
||||
if (strlen($row["device_setting_uuid"]) == 0) {
|
||||
unset($_POST["device_settings"][$x]["device_setting_uuid"]);
|
||||
}
|
||||
//increment the row
|
||||
$x++;
|
||||
}
|
||||
|
||||
|
||||
//prepare the array
|
||||
$array['device_profiles'][] = $_POST;
|
||||
|
||||
|
|
@ -246,6 +268,18 @@
|
|||
}
|
||||
}
|
||||
|
||||
//get device settings
|
||||
$sql = "SELECT * FROM v_device_settings ";
|
||||
$sql .= "WHERE device_profile_uuid = '".$device_profile_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);
|
||||
$device_settings[$x]['device_setting_name'] = '';
|
||||
$device_settings[$x]['device_setting_value'] = '';
|
||||
$device_settings[$x]['enabled'] = '';
|
||||
$device_settings[$x]['device_setting_description'] = '';
|
||||
|
||||
//show the header
|
||||
require_once "resources/header.php";
|
||||
$document['title'] = $text['title-profile'];
|
||||
|
|
@ -545,6 +579,89 @@
|
|||
echo " </td>";
|
||||
echo " </tr>";
|
||||
|
||||
//device settings
|
||||
echo " <tr>";
|
||||
echo " <td class='vncell' valign='top'>".$text['label-settings']."</td>";
|
||||
echo " <td class='vtable' align='left'>";
|
||||
echo " <table border='0' cellpadding='0' cellspacing='3'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td class='vtable'>".$text['label-device_setting_name']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-device_setting_value']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-enabled']."</td>\n";
|
||||
echo " <td class='vtable'>".$text['label-device_setting_description']."</td>\n";
|
||||
echo " <td> </td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
$x = 0;
|
||||
foreach($device_settings as $row) {
|
||||
//determine whether to hide the element
|
||||
if (strlen($device_setting_uuid) == 0) {
|
||||
$element['hidden'] = false;
|
||||
$element['visibility'] = "visibility:visible;";
|
||||
}
|
||||
else {
|
||||
$element['hidden'] = true;
|
||||
$element['visibility'] = "visibility:hidden;";
|
||||
}
|
||||
//add the primary key uuid
|
||||
if (strlen($row['device_setting_uuid']) > 0) {
|
||||
echo " <input name='device_settings[".$x."][device_setting_uuid]' type='hidden' value=\"".$row['device_setting_uuid']."\"/>\n";
|
||||
}
|
||||
|
||||
//show alls rows in the array
|
||||
echo "<tr>\n";
|
||||
echo "<td align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_subcategory]' style='width: 120px;' maxlength='255' value=\"".$row['device_setting_subcategory']."\"/>\n";
|
||||
echo "</td>\n";
|
||||
|
||||
echo "<td align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_value]' style='width: 120px;' maxlength='255' value=\"".$row['device_setting_value']."\"/>\n";
|
||||
echo "</td>\n";
|
||||
|
||||
echo "<td align='left'>\n";
|
||||
echo " <select class='formfld' name='device_settings[".$x."][device_setting_enabled]' style='width: 90px;'>\n";
|
||||
echo " <option value=''></option>\n";
|
||||
if ($row['device_setting_enabled'] == "true") {
|
||||
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='true'>".$text['label-true']."</option>\n";
|
||||
}
|
||||
if ($row['device_setting_enabled'] == "false") {
|
||||
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
else {
|
||||
echo " <option value='false'>".$text['label-false']."</option>\n";
|
||||
}
|
||||
echo " </select>\n";
|
||||
echo "</td>\n";
|
||||
|
||||
echo "<td align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_settings[".$x."][device_setting_description]' style='width: 150px;' maxlength='255' value=\"".$row['device_setting_description']."\"/>\n";
|
||||
echo "</td>\n";
|
||||
|
||||
if (strlen($text['description-settings']) > 0) {
|
||||
echo " <br>".$text['description-settings']."\n";
|
||||
}
|
||||
echo " </td>";
|
||||
|
||||
echo " <td>\n";
|
||||
if (strlen($row['device_setting_uuid']) > 0) {
|
||||
echo " <a href='device_setting_delete.php?device_profile_uuid=".$row['device_profile_uuid']."&id=".$row['device_setting_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
$x++;
|
||||
}
|
||||
/*
|
||||
echo " <td align='left'>\n";
|
||||
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n";
|
||||
*/
|
||||
echo " </table>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
|
||||
|
||||
if (permission_exists('device_profile_domain')) {
|
||||
echo "<tr>\n";
|
||||
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ else {
|
|||
if (isset($_GET["id"])) {
|
||||
$id = $_GET["id"];
|
||||
$device_uuid = $_GET["device_uuid"];
|
||||
$device_profile_uuid = $_GET["device_profile_uuid"];
|
||||
}
|
||||
|
||||
//delete device settings
|
||||
|
|
@ -53,10 +54,27 @@ else {
|
|||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
//delete profile device settings
|
||||
if (is_uuid($id) and is_uuid($device_profile_uuid)) {
|
||||
$sql = "delete from v_device_settings ";
|
||||
$sql .= "where device_profile_uuid = '$device_profile_uuid' ";
|
||||
$sql .= "and device_setting_uuid = '$id' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
//redirect to device profile
|
||||
if (is_uuid($device_profile_uuid)) {
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: device_profile_edit.php?id=".$device_profile_uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
//send a redirect
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
header("Location: device_edit.php?id=".$device_uuid);
|
||||
return;
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -472,6 +472,23 @@ include "root.php";
|
|||
unset($prep_statement_3);
|
||||
}
|
||||
|
||||
//get the device settings table in the provision category from the profile and update the provision array
|
||||
if ((strlen($device_uuid) > 0) and (strlen($device_profile_uuid) > 0)) {
|
||||
$sql = "SELECT * FROM v_device_settings ";
|
||||
$sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' ";
|
||||
$sql .= "AND device_setting_enabled = 'true' ";
|
||||
$prep_statement = $this->db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
$result_count = count($result);
|
||||
foreach($result as $row) {
|
||||
$key = $row['device_setting_subcategory'];
|
||||
$value = $row['device_setting_value'];
|
||||
$provision[$key] = $value;
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
//get the device settings table in the provision category and update the provision array
|
||||
if (strlen($device_uuid) > 0) {
|
||||
$sql = "SELECT * FROM v_device_settings ";
|
||||
|
|
|
|||
Loading…
Reference in New Issue