diff --git a/app/devices/app_config.php b/app/devices/app_config.php index 5ea0cff59c..1e01fc4a5f 100644 --- a/app/devices/app_config.php +++ b/app/devices/app_config.php @@ -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 diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index 78adb69185..6aabb82e13 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -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 " "; echo " "; +//device settings + echo " "; + echo " ".$text['label-settings'].""; + echo " "; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \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 " \n"; + } + + //show alls rows in the array + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + if (strlen($text['description-settings']) > 0) { + echo "
".$text['description-settings']."\n"; + } + echo " "; + + echo " \n"; + echo " \n"; + $x++; + } + /* + echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']." 
\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + if (strlen($row['device_setting_uuid']) > 0) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + */ + echo "
\n"; + echo " \n"; + echo " \n"; + + if (permission_exists('device_profile_domain')) { echo "\n"; echo "\n"; diff --git a/app/devices/device_setting_delete.php b/app/devices/device_setting_delete.php index 6db7497573..48b5c2ab44 100644 --- a/app/devices/device_setting_delete.php +++ b/app/devices/device_setting_delete.php @@ -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; -?> \ No newline at end of file +?> diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 86807675e9..f86385ecb3 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -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 ";