Enhanced Theme: New message alert display style and method.
Devices Edit: Check, alert and prevent duplicate MAC address.
This commit is contained in:
parent
e9fb5fbf02
commit
92c2da7f11
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
<?php
|
||||
|
||||
//show the content
|
||||
echo "<div align='center'>";
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
|
||||
|
|
@ -379,7 +419,7 @@ require_once "resources/require.php";
|
|||
echo " <td align=\"left\">\n";
|
||||
echo " <br>";
|
||||
|
||||
echo "<form method='post' name='frm' action=''>\n";
|
||||
echo "<form method='post' name='frm' id='frm' action=''>\n";
|
||||
echo "<div align='center'>\n";
|
||||
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
|
|
@ -404,7 +444,9 @@ require_once "resources/require.php";
|
|||
echo " ".$text['label-device_mac_address'].":\n";
|
||||
echo "</td>\n";
|
||||
echo "<td class='vtable' align='left'>\n";
|
||||
echo " <input class='formfld' type='text' name='device_mac_address' maxlength='255' value=\"$device_mac_address\">\n";
|
||||
echo " <input class='formfld' type='text' name='device_mac_address' id='device_mac_address' maxlength='255' value=\"$device_mac_address\" onblur=\"check_mac_duplicate(this.value, '".$device_uuid."');\">\n";
|
||||
echo " <div style='display: none;' id='duplicate_mac_response'></div>\n";
|
||||
echo " <input type='hidden' id='duplicate_mac_found' value=''>\n";
|
||||
echo "<br />\n";
|
||||
echo $text['description-device_mac_address']."\n";
|
||||
echo "</td>\n";
|
||||
|
|
@ -1048,9 +1090,9 @@ require_once "resources/require.php";
|
|||
echo " <tr>\n";
|
||||
echo " <td colspan='2' align='right'>\n";
|
||||
if ($action == "update") {
|
||||
echo " <input type='hidden' name='device_uuid' value='$device_uuid'>\n";
|
||||
echo " <input type='hidden' name='device_uuid' value='$device_uuid'>\n";
|
||||
}
|
||||
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
||||
echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"if (check_mac_duplicate(document.getElementById('device_mac_address').value, '".$device_uuid."')) { document.forms.frm.submit(); }\">\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>";
|
||||
echo "</table>";
|
||||
|
|
|
|||
|
|
@ -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('<?php echo PROJECT_PATH; ?>/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 {
|
|||
|
||||
<script language="javascript" type="text/javascript" src="<?php echo PROJECT_PATH; ?>/resources/jquery/jquery-1.8.3.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="<?php echo PROJECT_PATH; ?>/resources/jquery/jquery.autosize.input.js"></script>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
function display_message() {
|
||||
$(document).ready(function() {
|
||||
$("#message_container").animate({ opacity: 0.9 }, "fast").delay(1750).animate({marginTop: '-=200'}, 1000);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
||||
|
|
@ -978,20 +983,52 @@ legend {
|
|||
});
|
||||
</script>
|
||||
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
function display_message(msg, mood = 'default') {
|
||||
if (msg != '') {
|
||||
// insert temp div to get width w/o scroll bar
|
||||
var helper_div = $('<div />');
|
||||
$('#page').append(helper_div);
|
||||
inner_width = helper_div.width();
|
||||
helper_div.remove();
|
||||
// add class by mood
|
||||
$("#message_container").addClass('message_container_mood_'+mood);
|
||||
// output message
|
||||
$("#message_text").html(msg);
|
||||
$("#message_container").css({height: $("#message_text").css("height")});
|
||||
$("#message_container").css({width: inner_width});
|
||||
$("#message_text").animate({top: '+=200'}, 0).animate({opacity: 1}, "fast").delay(1750).animate({top: '-=200'}, 1000).animate({opacity: 0});
|
||||
$("#message_container").animate({top: '+=200'}, 0).animate({opacity: 0.7}, "fast").delay(1750).animate({top: '-=200'}, 1000).animate({opacity: 0}, function() {
|
||||
$("#message_container").removeClass('message_container_mood_'+mood);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body onload="display_message();">
|
||||
|
||||
<?php
|
||||
// set message_onload
|
||||
if (strlen($_SESSION['message']) > 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']);
|
||||
}
|
||||
?>
|
||||
|
||||
<body onload="<?php echo $onload;?>">
|
||||
|
||||
<div id='message_container' class='message_container_mood_default'></div>
|
||||
<div id='message_text' class='message_container_text_default'></div>
|
||||
|
||||
<?php
|
||||
// message block
|
||||
if (strlen($_SESSION['message']) > 0) {
|
||||
echo "<div id='message_container'>";
|
||||
echo " <div id='message_block'>";
|
||||
echo " <span class='text'>".$_SESSION['message']."</span>";
|
||||
echo " </div>";
|
||||
echo "</div>";
|
||||
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 {
|
||||
?>
|
||||
<div class='main_content' style='position: absolute; top: 0; left: 0; right: 0; bottom: 0; padding: 0;'>
|
||||
<div id="main_content" class='main_content' style='position: absolute; top: 0; left: 0; right: 0; bottom: 0; padding: 0;'>
|
||||
<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'>
|
||||
<tr>
|
||||
<td align='center' valign='middle'>
|
||||
|
|
|
|||
Loading…
Reference in New Issue