From 0c956d672882896a01ca3eda2ccfe948a8d9c6ad Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 11 Oct 2016 12:11:33 -0400 Subject: [PATCH] fix logic when disabling a monitor --- web/includes/actions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index 8cf17ff6e..18c4fe128 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -289,14 +289,15 @@ if ( !empty($action) ) { if ( !empty($_REQUEST['mid']) && canEdit( 'Monitors', $_REQUEST['mid'] ) ) { $mid = validInt($_REQUEST['mid']); if ( $action == 'function' ) { - $monitor = dbFetchOne( "SELECT * FROM Monitors WHERE Id=?", NULL, array($mid) ); + $monitor = dbFetchOne( 'SELECT * FROM Monitors WHERE Id=?', NULL, array($mid) ); $newFunction = validStr($_REQUEST['newFunction']); - $newEnabled = isset( $_REQUEST['newEnabled'] ) and $_REQUEST['newEnabled'] != '1' ? '0' : '1'; + # Because we use a checkbox, it won't get passed in the request. So not being in _REQUEST means 0 + $newEnabled = ( !isset( $_REQUEST['newEnabled'] ) or $_REQUEST['newEnabled'] != '1' ) ? '0' : '1'; $oldFunction = $monitor['Function']; $oldEnabled = $monitor['Enabled']; if ( $newFunction != $oldFunction || $newEnabled != $oldEnabled ) { - dbQuery( "update Monitors set Function=?, Enabled=? where Id=?", array( $newFunction, $newEnabled, $mid ) ); + dbQuery( 'UPDATE Monitors SET Function=?, Enabled=? WHERE Id=?', array( $newFunction, $newEnabled, $mid ) ); $monitor['Function'] = $newFunction; $monitor['Enabled'] = $newEnabled;