From 92c2da7f11f02dbddbd24b726a58be7e6362b817 Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Sat, 2 Aug 2014 02:16:46 +0000 Subject: [PATCH] Enhanced Theme: New message alert display style and method. Devices Edit: Check, alert and prevent duplicate MAC address. --- app/devices/device_edit.php | 82 ++++++++++++++++++------ themes/enhanced/template.php | 121 +++++++++++++++++++++++------------ 2 files changed, 141 insertions(+), 62 deletions(-) diff --git a/app/devices/device_edit.php b/app/devices/device_edit.php index dd26fd05c7..2b99a5bf31 100644 --- a/app/devices/device_edit.php +++ b/app/devices/device_edit.php @@ -41,6 +41,31 @@ require_once "resources/require.php"; $text[$key] = $value[$_SESSION['domain']['language']['code']]; } +// check duplicate mac address + if ($_GET["mac"] != '' && $_GET["mac"] != "000000000000") { + $sql = "select "; + $sql .= "d2.domain_name "; + $sql .= "from "; + $sql .= "v_devices as d1, "; + $sql .= "v_domains as d2 "; + $sql .= "where "; + $sql .= "d1.domain_uuid = d2.domain_uuid and "; + $sql .= "d1.device_mac_address = '".check_str($_GET["mac"])."' "; + if ($_GET["id"] != '') { + $sql .= " and d1.device_uuid <> '".check_str($_GET["id"])."' "; + } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['domain_name'] != '') { + echo $text['message-duplicate'].((if_group("superadmin") && $_SESSION["domain_name"] != $row["domain_name"]) ? ": ".$row["domain_name"] : null); + } + } + unset($prep_statement); + exit; + } + //include the device class require_once "app/devices/resources/classes/device.php"; @@ -193,21 +218,7 @@ require_once "resources/require.php"; //allow duplicates to be used as templaes } else { - $sql = "SELECT count(*) AS num_rows FROM v_devices "; - $sql .= "WHERE device_mac_address = '".$device_mac_address."' "; - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] == "0") { - $save = true; - } - else { - $save = false; - $_SESSION['message'] = $text['message-duplicate']; - } - } - unset($prep_statement); + $save = true; } } else { @@ -237,6 +248,7 @@ require_once "resources/require.php"; if ($action == "add") { //save the message to a session variable $_SESSION['message'] = $text['message-add']; + $_SESSION['message_mood'] = 'positive'; //redirect the browser header("Location: device_edit.php?id=$device_uuid"); exit; @@ -244,6 +256,7 @@ require_once "resources/require.php"; if ($action == "update") { //save the message to a session variable $_SESSION['message'] = $text['message-update']; + $_SESSION['message_mood'] = 'positive'; } } } @@ -369,9 +382,36 @@ require_once "resources/require.php"; obj[0].parentNode.removeChild(obj[1]); obj[0].parentNode.removeChild(obj[2]); } + + + function check_mac_duplicate(mac_addr, device_uuid_to_ignore) { + if (mac_addr != '') { + var response; + check_url = "device_edit.php?mac="+mac_addr+"&id="+device_uuid_to_ignore; + $("#duplicate_mac_response").load(check_url, function() { + var duplicate_mac_response = $("#duplicate_mac_response").html(); + if (duplicate_mac_response != '') { + $('#device_mac_address').addClass('formfld_highlight_bad'); + display_message(duplicate_mac_response, 'negative'); + $('#duplicate_mac_found').val(true); + } + else { + $('#device_mac_address').removeClass('formfld_highlight_bad'); + $('#duplicate_mac_found').val(false); + } + }); + return ($('#duplicate_mac_found').val() == "true") ? false : true; + } + else { + return true; + } + } + + + + "; echo "\n"; @@ -379,7 +419,7 @@ require_once "resources/require.php"; echo "
\n"; echo "
"; - echo "
\n"; + echo "\n"; echo "
\n"; echo "\n"; echo "\n"; @@ -404,7 +444,9 @@ require_once "resources/require.php"; echo " ".$text['label-device_mac_address'].":\n"; echo "\n"; echo "\n"; @@ -1048,9 +1090,9 @@ require_once "resources/require.php"; echo " \n"; echo " \n"; echo " "; echo "
\n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; echo "
\n"; echo $text['description-device_mac_address']."\n"; echo "
\n"; if ($action == "update") { - echo " \n"; + echo " \n"; } - echo " \n"; + echo " \n"; echo "
"; diff --git a/themes/enhanced/template.php b/themes/enhanced/template.php index c550625782..2bd59b8fae 100644 --- a/themes/enhanced/template.php +++ b/themes/enhanced/template.php @@ -759,41 +759,55 @@ legend { /* end the menu css*/ - #message_container { + z-index: 99998; + position: absolute; + top: -200px; + left: 0; + right: 0; + height: 30px; + filter: alpha(opacity=0); + opacity: 0; + -moz-opacity:0; + -khtml-opacity: 0; + padding: 8px 0; + } + + #message_text { z-index: 99999; position: absolute; + top: -200px; left: 0; - top: 0; right: 0; filter: alpha(opacity=0); opacity: 0; -moz-opacity:0; -khtml-opacity: 0; - } - - #message_block { margin: 0 auto; - width: 300px; - height: auto; - background-color: #000; - background-repeat: repeat-x; - background-image: url('/themes/enhanced/images/background_black.png'); - background-position: top center; - padding: 6px 0 8px 0; - -webkit-border-radius: 0 0 3px 3px; - -moz-border-radius: 0 0 3px 3px; - border-radius: 0 0 3px 3px; + vertical-align: middle; + padding: 8px 0; text-align: center; - } - - #message_block .text { font-family: arial, san-serif; - font-size: 10pt; font-weight: bold; - color: #fff; + font-size: 10pt; + color: #000; } + .message_container_mood_default { + background-color: #ccc; + } + + .message_container_mood_negative { + background-color: #ffcdcd; + } + + .message_container_mood_alert { + background-color: #feff9d; + } + + .message_container_mood_positive { + background-color: #ccffcc; + } #domains_show_icon { filter: alpha(opacity=50); @@ -812,7 +826,7 @@ legend { } #domains_container { - z-index: 99998; + z-index: 99990; position: absolute; right: 0; top: 0; @@ -909,15 +923,6 @@ legend { - - - + + - + + 0) { + $message_text = addslashes($_SESSION['message']); + $message_mood = $_SESSION['message_mood']; + + $onload .= "display_message('".$message_text."'"; + if ($message_mood != '') { + $onload .= ", '".$message_mood."'"; + } + $onload .= "); "; + unset($_SESSION['message'], $_SESSION['message_mood']); +} +?> + + + +
+
0) { - echo "
"; - echo "
"; - echo " ".$_SESSION['message'].""; - echo "
"; - echo "
"; - unset($_SESSION['message']); - } - //logged in show the domains block if (strlen($_SESSION["username"]) > 0 && permission_exists("domain_select") && count($_SESSION['domains']) > 1) { @@ -1306,7 +1343,7 @@ legend { // default login being used else { ?> -
+