fix state actions

This commit is contained in:
Isaac Connor 2019-02-05 12:35:06 -05:00
parent 604dbf8776
commit c54fe7e89a
5 changed files with 16 additions and 11 deletions

View File

@ -29,7 +29,7 @@ if ( $action == 'state' ) {
packageControl($_REQUEST['runState']);
$refreshParent = true;
}
} elseif ( $action == 'save' ) {
} else if ( $action == 'save' ) {
if ( !empty($_REQUEST['runState']) || !empty($_REQUEST['newState']) ) {
$sql = 'SELECT Id,Function,Enabled FROM Monitors ORDER BY Id';
$definitions = array();
@ -41,8 +41,9 @@ if ( $action == 'state' ) {
$_REQUEST['runState'] = $_REQUEST['newState'];
dbQuery('REPLACE INTO States SET Name=?, Definition=?', array($_REQUEST['runState'],$definition));
}
} elseif ( $action == 'delete' ) {
} else if ( $action == 'delete' ) {
if ( isset($_REQUEST['runState']) )
dbQuery('DELETE FROM States WHERE Name=?', array($_REQUEST['runState']));
}
$view = 'console';
?>

View File

@ -29,14 +29,15 @@ if ( empty($_COOKIE['zmBandwidth']) )
//if ( $skinLangFile = loadLanguage( ZM_SKIN_PATH ) )
//require_once( $skinLangFile );
foreach ( getSkinIncludes( 'includes/config.php' ) as $includeFile )
foreach ( getSkinIncludes('includes/config.php') as $includeFile )
require_once $includeFile;
foreach ( getSkinIncludes( 'includes/functions.php' ) as $includeFile )
foreach ( getSkinIncludes('includes/functions.php') as $includeFile )
require_once $includeFile;
if ( empty($view) )
if ( empty($view) ) {
$view = isset($user)?'console':'login';
}
if ( !isset($user) && ZM_OPT_USE_AUTH && ZM_AUTH_TYPE == 'remote' && !empty( $_SERVER['REMOTE_USER']) ) {
$view = 'postlogin';

View File

@ -12,13 +12,15 @@
function () {
// Append '?(GET query)' to URL if the GET query is not empty.
var querySuffix = "<?php
if (!empty($_POST["postLoginQuery"])) {
parse_str($_POST["postLoginQuery"], $queryParams);
echo "?" . http_build_query($queryParams);
}
if (!empty($_POST['postLoginQuery'])) {
parse_str($_POST['postLoginQuery'], $queryParams);
echo '?' . http_build_query($queryParams);
}
?>";
var newUrl = thisUrl + querySuffix;
//var newUrl = thisUrl + querySuffix;
var newUrl = '<?php echo $_SERVER['PHP_SELF'] ?>' + querySuffix;
console.log("Redirecting to" + newUrl + ' ' + thisUrl);
window.location.replace(newUrl);
}
).delay( 500 );

View File

@ -38,6 +38,7 @@ $j(document).ready(function() {
});
function stateStuff(action, runState, newState) {
// the state action will redirect to console
var formData = {
'view': 'state',
'action': action,

View File

@ -24,7 +24,7 @@ if ( !canEdit('System') ) {
}
?>
<div id="modalState" class="modal fade">
<form class="form-horizontal" name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<form class="form-horizontal" name="contentForm" id="contentForm" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>?view=state">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">