diff --git a/web/ajax/modals/shutdown.php b/web/ajax/modals/shutdown.php new file mode 100644 index 000000000..a461f0074 --- /dev/null +++ b/web/ajax/modals/shutdown.php @@ -0,0 +1,68 @@ +'.implode('
', $output).'

'.PHP_EOL; +} + +$cancel_str = ''; +if ( isset($_POST['when']) and ($_POST['when'] != 'NOW') and ($action != 'cancel') ) { + $cancel_str = '

You may cancel this shutdown by clicking '.translate('Cancel').'

'.PHP_EOL; +} + +$cancel_btn = ''; +if ( isset($_POST['when']) and ($_POST['when'] != 'NOW') and ($action != 'cancel') ) { + $cancel_btn = ''.PHP_EOL; +} + +?> + diff --git a/web/includes/actions/logout.php b/web/includes/actions/logout.php index a80511aa7..116ae278c 100644 --- a/web/includes/actions/logout.php +++ b/web/includes/actions/logout.php @@ -23,7 +23,7 @@ if ( $action == 'logout' ) { userLogout(); $view = 'login'; } elseif ( $action == 'config' ) { - $redirect = '?view=user&uid='.$user['Id']; + $redirect = '?view=user&prev=console&uid='.$user['Id']; } ?> diff --git a/web/includes/actions/user.php b/web/includes/actions/user.php index 496b6b214..372108355 100644 --- a/web/includes/actions/user.php +++ b/web/includes/actions/user.php @@ -66,9 +66,7 @@ if ( $action == 'Save' ) { } else { dbQuery('INSERT INTO Users SET '.implode(', ', $changes)); } - $refreshParent = true; } # end if changes - $redirect = '?view=options&tab=users'; } else if ( ZM_USER_SELF_EDIT and ( $_REQUEST['uid'] == $user['Id'] ) ) { $uid = $user['Id']; @@ -99,9 +97,7 @@ if ( $action == 'Save' ) { zm_session_start(); generateAuthHash(ZM_AUTH_HASH_IPS, true); session_write_close(); - $refreshParent = true; } - $redirect = '?view=options&tab=users'; } } // end if $action == user ?> diff --git a/web/includes/functions.php b/web/includes/functions.php index d2610c3c3..32c5c59d3 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -424,6 +424,9 @@ function deleteEvent($event) { } # CAN EDIT } +/** + * $label must be already escaped. It can't be done here since it sometimes contains HTML tags. + */ function makeLink($url, $label, $condition=1, $options='') { $string = ''; if ( $condition ) { @@ -443,32 +446,6 @@ function makeHelpLink($ohndx) { return $string; } -/** - * $label must be already escaped. It can't be done here since it sometimes contains HTML tags. - */ -function makePopupLink($url, $winName, $winSize, $label, $condition=1, $options='') { - // Avoid double-encoding since some consumers incorrectly pass a pre-escaped URL. - $string = ''; - } else { - $string .= '>'; - } - $string .= $label; - $string .= ''; - return $string; -} - function makeButton($url, $buttonValue, $condition=1, $options='') { $string = ''.PHP_EOL; + $result .= ''.PHP_EOL; } } else if ( canView('System') ) { diff --git a/web/skins/classic/js/skin.js b/web/skins/classic/js/skin.js index a7781b961..c6171a47a 100644 --- a/web/skins/classic/js/skin.js +++ b/web/skins/classic/js/skin.js @@ -21,7 +21,6 @@ // This file should only contain static JavaScript and no php. // Use skin.js.php for JavaScript that need pre-processing // -var popupOptions = "resizable,scrollbars,status=no,toolbar=yes"; // Globally define the icons used in the bootstrap-table top-right toolbar var icons = { @@ -59,88 +58,6 @@ function checkSize() { } } -// Deprecated -function newWindow( url, name, width, height ) { - window.open( url, name, popupOptions+",width="+width+",height="+height ); -} - -function getPopupSize( tag, width, height ) { - if ( typeof popupSizes == 'undefined' ) { - Error("Can't find any window sizes"); - return {'width': 0, 'height': 0}; - } - var popupSize = Object.clone(popupSizes[tag]); - if ( !popupSize ) { - Error("Can't find window size for tag '"+tag+"'"); - return {'width': 0, 'height': 0}; - } - if ( popupSize.width && popupSize.height ) { - if ( width || height ) { - Warning("Ignoring passed dimensions "+width+"x"+height+" when getting popup size for tag '"+tag+"'"); - } - return popupSize; - } - if ( popupSize.addWidth ) { - popupSize.width = popupSize.addWidth; - if ( !width ) { - Error("Got addWidth but no passed width when getting popup size for tag '"+tag+"'"); - } else { - popupSize.width += parseInt(width); - } - } else if ( width ) { - popupSize.width = width; - Error("Got passed width but no addWidth when getting popup size for tag '"+tag+"'"); - } - if ( popupSize.minWidth && popupSize.width < popupSize.minWidth ) { - Warning("Adjusting to minimum width when getting popup size for tag '"+tag+"'"); - popupSize.width = popupSize.minWidth; - } - if ( popupSize.addHeight ) { - popupSize.height = popupSize.addHeight; - if ( !height ) { - Error("Got addHeight but no passed height when getting popup size for tag '"+tag+"'"); - } else { - popupSize.height += parseInt(height); - } - } else if ( height ) { - popupSize.height = height; - Error("Got passed height but no addHeight when getting popup size for tag '"+tag+"'"); - } - if ( popupSize.minHeight && ( popupSize.height < popupSize.minHeight ) ) { - Warning("Adjusting to minimum height ("+popupSize.minHeight+") when getting popup size for tag '"+tag+"' because calculated height is " + popupSize.height); - popupSize.height = popupSize.minHeight; - } - return popupSize; -} - -function zmWindow(sub_url) { - var zmWin = window.open( 'https://www.zoneminder.com'+(sub_url?sub_url:''), 'ZoneMinder' ); - if ( ! zmWin ) { - // if popup blocking is enabled, the popup won't be defined. - console.log("Please disable popup blocking."); - } else { - zmWin.focus(); - } -} - -function createPopup( url, name, tag, width, height ) { - var popupSize = getPopupSize( tag, width, height ); - var popupDimensions = ""; - if ( popupSize.width > 0 ) { - popupDimensions += ",width="+popupSize.width; - } - if ( popupSize.height > 0 ) { - popupDimensions += ",height="+popupSize.height; - } - var popup = window.open( url+"&popup=1", name, popupOptions+popupDimensions ); - if ( ! popup ) { - // if popup blocking is enabled, the popup won't be defined. - console.log("Please disable popup blocking."); - } else { - popup.focus(); - } -} - // Polyfill for NodeList.prototype.forEach on IE. if (window.NodeList && !NodeList.prototype.forEach) { NodeList.prototype.forEach = Array.prototype.forEach; @@ -155,26 +72,6 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { }); }); - document.querySelectorAll(".popup-link").forEach(function(el) { - el.addEventListener("click", function onClick(evt) { - var el = this; - var url; - if ( el.hasAttribute("href") ) { - // - url = el.getAttribute("href"); - } else { - // buttons - url = el.getAttribute("data-url"); - } - var name = el.getAttribute("data-window-name"); - var tag = el.getAttribute("data-window-tag"); - var width = el.getAttribute("data-window-width"); - var height = el.getAttribute("data-window-height"); - evt.preventDefault(); - createPopup(url, name, tag, width, height); - }); - }); - document.querySelectorAll(".zmlink").forEach(function(el) { el.addEventListener("click", function onClick(evt) { var el = this; @@ -271,46 +168,22 @@ window.addEventListener("DOMContentLoaded", function onSkinDCL() { }); }); -function createEventPopup( eventId, eventFilter, width, height ) { +function openEvent( eventId, eventFilter ) { var url = '?view=event&eid='+eventId; if ( eventFilter ) { url += eventFilter; } - var name = 'zmEvent'; - var popupSize = getPopupSize( 'event', width, height ); - var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height ); - if ( ! popup ) { - // if popup blocking is enabled, the popup won't be defined. - console.log("Please disable popup blocking."); - } else { - popup.focus(); - } + window.location.assign(url); } -function createFramesPopup( eventId, width, height ) { +function openFrames( eventId ) { var url = '?view=frames&eid='+eventId; - var name = 'zmFrames'; - var popupSize = getPopupSize( 'frames', width, height ); - var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height ); - if ( ! popup ) { - // if popup blocking is enabled, the popup won't be defined. - console.log("Please disable popup blocking."); - } else { - popup.focus(); - } + window.location.assign(url); } -function createFramePopup( eventId, frameId, width, height ) { +function openFrame( eventId, frameId, width, height ) { var url = '?view=frame&eid='+eventId+'&fid='+frameId; - var name = 'zmFrame'; - var popupSize = getPopupSize( 'frame', width, height ); - var popup = window.open( url, name, popupOptions+",width="+popupSize.width+",height="+popupSize.height ); - if ( ! popup ) { - // if popup blocking is enabled, the popup won't be defined. - console.log("Please disable popup blocking."); - } else { - popup.focus(); - } + window.location.assign(url); } function windowToFront() { @@ -577,17 +450,6 @@ function confirmDelete( message ) { return ( confirm( message?message:'Are you sure you wish to delete?' ) ); } -if ( refreshParent ) { - refreshParentWindow(); -} - -if ( focusWindow ) { - windowToFront(); -} -if ( closePopup ) { - closeWindow(); -} - window.addEventListener( 'DOMContentLoaded', checkSize ); function convertLabelFormat(LabelFormat, monitorName) { @@ -956,3 +818,28 @@ function exportEvent() { .fail(logAjaxFail); $j('#exportProgress').removeClass( 'invisible' ); } + +// Load the Function modal on page load +function getShutdownModal() { + $j.getJSON(thisUrl + '?request=modal&modal=shutdown') + .done(function(data) { + if ( $j('#shutdownModal').length ) { + $j('#shutdownModal').replaceWith(data.html); + } else { + $j("body").append(data.html); + } + // Manage the Shutdown modal + $j('#shutdownModal').modal('show'); + // Redirect to the current view after the form is submitted - avoids a blank screen + $j('#shutdownForm').append(''); + $j('#restartBtn').click(function(evt) { + evt.preventDefault(); + $j('#shutdownForm').submit(); + }); + $j('#shutdownBtn').click(function(evt) { + evt.preventDefault(); + $j('#shutdownForm').submit(); + }); + }) + .fail(logAjaxFail); +} diff --git a/web/skins/classic/views/js/cycle.js.php b/web/skins/classic/views/js/cycle.js.php index f53ab006d..7bcd4497c 100644 --- a/web/skins/classic/views/js/cycle.js.php +++ b/web/skins/classic/views/js/cycle.js.php @@ -18,7 +18,7 @@ monitorData[monitorData.length] = { 'width': ViewWidth() ?>, 'height':ViewHeight() ?>, 'url': 'UrlToIndex() ?>', - 'onclick': function(){createPopup( '?view=watch&mid=Id() ?>', 'zmWatchId() ?>', 'watch', ViewWidth(), $monitor->PopupScale() ); ?>, ViewHeight(), $monitor->PopupScale() ); ?> );}, + 'onclick': function(){window.location.assign( '?view=watch&mid=Id() ?>' );}, 'type': 'Type() ?>', 'refresh': 'Refresh() ?>' }; diff --git a/web/skins/classic/views/js/filter.js b/web/skins/classic/views/js/filter.js index 12be01330..eadfbfd41 100644 --- a/web/skins/classic/views/js/filter.js +++ b/web/skins/classic/views/js/filter.js @@ -174,7 +174,6 @@ function submitToMontageReview(element) { function submitToExport(element) { var form = element.form; window.location.assign('?view=export&'+$j(form).serialize()); - //createPopup('?view=export&filter_id='+form.elements['Id'].value, 'zmExport', 'export' ); } function executeFilter( element ) { diff --git a/web/skins/classic/views/js/montage.js.php b/web/skins/classic/views/js/montage.js.php index 5a2aef2ed..9b6962119 100644 --- a/web/skins/classic/views/js/montage.js.php +++ b/web/skins/classic/views/js/montage.js.php @@ -37,7 +37,7 @@ monitorData[monitorData.length] = { 'width': ViewWidth() ?>, 'height':ViewHeight() ?>, 'url': 'UrlToIndex( ZM_MIN_STREAMING_PORT ? ($monitor->Id() + ZM_MIN_STREAMING_PORT) : '') ?>', - 'onclick': function(){createPopup( '?view=watch&mid=Id() ?>', 'zmWatchId() ?>', 'watch', ViewWidth(), $monitor->PopupScale() ); ?>, ViewHeight(), $monitor->PopupScale() ); ?> );}, + 'onclick': function(){window.location.assign( '?view=watch&mid=Id() ?>' );}, 'type': 'Type() ?>', 'refresh': 'Refresh() ?>' }; diff --git a/web/skins/classic/views/js/watch.js b/web/skins/classic/views/js/watch.js index 496426a34..1b437325c 100644 --- a/web/skins/classic/views/js/watch.js +++ b/web/skins/classic/views/js/watch.js @@ -562,11 +562,9 @@ function getEventCmdResponse( respObj, respText ) { var link = new Element('a', { 'href': '#', 'events': { - 'click': createEventPopup.pass( [ + 'click': openEvent.pass( [ zm_event.Id, - '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', - zm_event.Width, - zm_event.Height + '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1' ] ) } }); @@ -576,11 +574,9 @@ function getEventCmdResponse( respObj, respText ) { link = new Element('a', { 'href': '#', 'events': { - 'click': createEventPopup.pass( [ + 'click': openEvent.pass( [ zm_event.Id, - '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1&popup=1', - zm_event.Width, - zm_event.Height + '&filter[Query][terms][0][attr]=MonitorId&filter[Query][terms][0][op]=%3d&filter[Query][terms][0][val]='+monitorId+'&page=1' ] ) } }); @@ -590,11 +586,11 @@ function getEventCmdResponse( respObj, respText ) { row.getElement('td.colTime').set('text', zm_event.StartTime); row.getElement('td.colSecs').set('text', zm_event.Length); - link = new Element('a', {'href': '#', 'events': {'click': createFramesPopup.pass( [zm_event.Id, zm_event.Width, zm_event.Height] )}}); + link = new Element('a', {'href': '#', 'events': {'click': openFrames.pass( [zm_event.Id] )}}); link.set('text', zm_event.Frames+'/'+zm_event.AlarmFrames); link.inject(row.getElement('td.colFrames')); - link = new Element('a', {'href': '#', 'events': {'click': createFramePopup.pass( [zm_event.Id, '0', zm_event.Width, zm_event.Height] )}}); + link = new Element('a', {'href': '#', 'events': {'click': openFrame.pass( [zm_event.Id, '0'] )}}); link.set('text', zm_event.AvgScore+'/'+zm_event.MaxScore); link.inject(row.getElement('td.colScore')); diff --git a/web/skins/classic/views/shutdown.php b/web/skins/classic/views/shutdown.php deleted file mode 100644 index 25d5d3d34..000000000 --- a/web/skins/classic/views/shutdown.php +++ /dev/null @@ -1,79 +0,0 @@ - - -
- -
-ZM_PATH_SHUTDOWN is not defined. This is normally configured in /etc/zm/conf.d/01-system-paths.conf
'; - } else if ( !file_exists(ZM_PATH_SHUTDOWN) ) { - echo '
Path does not exist for ZM_PATH_SHUTDOWN. Current value is '.ZM_PATH_SHUTDOWN.'
'; - } else { -?> - -
- -'.implode('
', $output).'

'; - } - if ( isset($_POST['when']) and ($_POST['when'] != 'NOW') and ($action != 'cancel') ) { - echo '

You may cancel this shutdown by clicking '.translate('Cancel').'

'; - } -?> -

Warning

- This command will either shutdown or restart all ZoneMinder Servers
-

-

- - -

-
- - - - - - -
-
- -
- - diff --git a/web/skins/classic/views/user.php b/web/skins/classic/views/user.php index 06dde73a1..8d795809a 100644 --- a/web/skins/classic/views/user.php +++ b/web/skins/classic/views/user.php @@ -69,6 +69,7 @@ xhtmlHeaders(__FILE__, translate('User').' - '.$newUser->Username());
+