Merge branch 'release-1.34' of github.com:ZoneMinder/zoneminder into release-1.34

This commit is contained in:
Isaac Connor 2020-07-04 09:04:38 -04:00
commit 8a35ae2daf
8 changed files with 76 additions and 61 deletions

View File

@ -87,6 +87,7 @@ $SLANG = array(
'Actual' => 'Actual',
'AddNewControl' => 'Add New Control',
'AddNewMonitor' => 'Add',
'AddMonitorDisabled' => 'Your user is not allowed to add a new monitor',
'AddNewServer' => 'Add New Server',
'AddNewStorage' => 'Add New Storage',
'AddNewUser' => 'Add New User',

View File

@ -178,7 +178,7 @@ getBodyTopHTML();
<div class="container-fluid">
<button type="button" name="addBtn" data-on-click-this="addMonitor"
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled"' ?>
<?php echo (canEdit('Monitors') && !$user['MonitorIds']) ? '' : ' disabled="disabled" title="'.translate('AddMonitorDisabled').'"' ?>
>
<i class="material-icons md-18">add_circle</i>
&nbsp;<?php echo translate('AddNewMonitor') ?>

View File

@ -58,32 +58,6 @@ $heights = array(
'1080px' => '1080px',
);
session_start();
if ( isset($_REQUEST['scale']) ) {
$options['scale'] = validInt($_REQUEST['scale']);
} else if ( isset($_COOKIE['zmCycleScale']) ) {
$options['scale'] = $_COOKIE['zmCycleScale'];
}
if ( !isset($options['scale']) )
$options['scale'] = 100;
if ( isset($_COOKIE['zmCycleWidth']) and $_COOKIE['zmCycleWidth'] ) {
$_SESSION['zmCycleWidth'] = $options['width'] = $_COOKIE['zmCycleWidth'];
#} elseif ( isset($_SESSION['zmCycleWidth']) and $_SESSION['zmCycleWidth'] ) {
#$options['width'] = $_SESSION['zmCycleWidth'];
} else
$options['width'] = '';
if ( isset($_COOKIE['zmCycleHeight']) and $_COOKIE['zmCycleHeight'] )
$_SESSION['zmCycleHeight'] = $options['height'] = $_COOKIE['zmCycleHeight'];
#else if ( isset($_SESSION['zmCycleHeight']) and $_SESSION['zmCycleHeight'] )
#$options['height'] = $_SESSION['zmCycleHeight'];
else
$options['height'] = '';
session_write_close();
$monIdx = 0;
$monitors = array();
@ -113,6 +87,40 @@ if ( $monitors ) {
$monitor = $monitors[$monIdx];
$nextMid = $monIdx==(count($monitors)-1)?$monitors[0]->Id():$monitors[$monIdx+1]->Id();
}
if ( !$monitor ) {
ZM\Error('There was no monitor to display.');
}
session_start();
if ( isset($_REQUEST['scale']) ) {
$options['scale'] = validInt($_REQUEST['scale']);
} else if ( isset($_COOKIE['zmCycleScale']) ) {
$options['scale'] = $_COOKIE['zmCycleScale'];
} else if ( $monitor ) {
$options['scale'] = $monitor->DefaultScale();
}
if ( !isset($options['scale']) )
$options['scale'] = 100;
if ( isset($_COOKIE['zmCycleWidth']) and $_COOKIE['zmCycleWidth'] ) {
$_SESSION['zmCycleWidth'] = $options['width'] = $_COOKIE['zmCycleWidth'];
#} elseif ( isset($_SESSION['zmCycleWidth']) and $_SESSION['zmCycleWidth'] ) {
#$options['width'] = $_SESSION['zmCycleWidth'];
} else {
$options['width'] = '';
}
if ( isset($_COOKIE['zmCycleHeight']) and $_COOKIE['zmCycleHeight'] ) {
$_SESSION['zmCycleHeight'] = $options['height'] = $_COOKIE['zmCycleHeight'];
#else if ( isset($_SESSION['zmCycleHeight']) and $_SESSION['zmCycleHeight'] )
#$options['height'] = $_SESSION['zmCycleHeight'];
} else {
$options['height'] = '';
}
session_write_close();
ZM\Logger::Debug(print_r($options,true));

View File

@ -35,7 +35,7 @@ xhtmlHeaders(__FILE__, translate('Error') );
<?php echo translate('ContactAdmin') ?>
</p>
<p>
<a href="#" data-on-click="closeWindow"><?php echo translate('Close') ?></a>
<button type="button" data-on-click="closeWindow"><?php echo translate('Close') ?></button>
</p>
</div>
</div>

View File

@ -9,24 +9,27 @@ function cyclePause() {
$('pauseBtn').disabled = true;
$('playBtn').disabled = false;
}
function cycleStart() {
periodical_id = nextCycleView.periodical(cycleRefreshTimeout);
$('pauseBtn').disabled = false;
$('playBtn').disabled = true;
}
function cycleNext() {
monIdx ++;
if ( monIdx >= monitorData.length ) {
monIdx = 0;
}
if ( !monitorData[monIdx] ) {
console.log("No monitorData for " + monIdx);
console.log('No monitorData for ' + monIdx);
}
window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout);
}
function cyclePrev() {
if (monIdx) {
if ( monIdx ) {
monIdx -= 1;
} else {
monIdx = monitorData.length - 1;
@ -71,7 +74,7 @@ function changeSize() {
streamImg.style.width = width ? width : null;
streamImg.style.height = height ? height : null;
} else {
console.log("Did not find liveStream"+monitorData[monIdx].id);
console.log('Did not find liveStream'+monitorData[monIdx].id);
}
$('scale').set('value', '');
Cookie.write('zmCycleScale', '', {duration: 10*365});
@ -96,7 +99,7 @@ function changeScale() {
return;
}
if ( scale != '0' ) {
if ( scale != '0' && scale != '' && scale != 'auto' ) {
if ( newWidth ) {
monitor_frame.css('width', newWidth+'px');
}
@ -107,33 +110,36 @@ function changeScale() {
monitor_frame.css('width', '100%');
monitor_frame.css('height', 'auto');
}
/*Stream could be an applet so can't use moo tools*/
var streamImg = $j('#liveStream'+monitorData[monIdx].id)[0];
if ( streamImg ) {
if ( streamImg.nodeName == 'IMG' ) {
var src = streamImg.src;
streamImg.src = '';
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
src = src.replace(/scale=[\.\d]+/i, 'scale='+scale);
if ( scale != '0' ) {
src = src.replace(/width=[\.\d]+/i, 'width='+newWidth);
src = src.replace(/height=[\.\d]+/i, 'height='+newHeight);
} else {
src = src.replace(/width=[\.\d]+/i, 'width='+monitorData[monIdx].width);
src = src.replace(/height=[\.\d]+/i, 'height='+monitorData[monIdx].height);
}
streamImg.src = src;
}
if ( scale != '0' ) {
streamImg.style.width = newWidth+'px';
streamImg.style.height = newHeight+'px';
} else {
streamImg.style.width = '100%';
streamImg.style.height = 'auto';
}
} else {
if ( !streamImg ) {
console.log("Did not find liveStream"+monitorData[monIdx].id);
return;
}
if ( streamImg.nodeName == 'IMG' ) {
var src = streamImg.src;
streamImg.src = '';
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
src = src.replace(/scale=[\.\d]+/i, 'scale='+scale);
if ( scale != '0' && scale != '' && scale != 'auto' ) {
src = src.replace(/width=[\.\d]+/i, 'width='+newWidth);
src = src.replace(/height=[\.\d]+/i, 'height='+newHeight);
} else {
src = src.replace(/width=[\.\d]+/i, 'width='+monitorData[monIdx].width);
src = src.replace(/height=[\.\d]+/i, 'height='+monitorData[monIdx].height);
}
streamImg.src = src;
}
if ( scale != '0' && scale != '' && scale != 'auto' ) {
streamImg.style.width = newWidth+'px';
streamImg.style.height = newHeight+'px';
} else {
streamImg.style.width = '100%';
streamImg.style.height = 'auto';
}
} // end function changeScale()

View File

@ -21,7 +21,7 @@
require_once('includes/Server.php');
require_once('includes/Storage.php');
if ( !canView('Monitors') ) {
if ( !canEdit('Monitors', empty($_REQUEST['mid'])?0:$_REQUEST['mid']) ) {
$view = 'error';
return;
}

View File

@ -18,12 +18,12 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView('Monitors') ) {
$mid = empty($_REQUEST['mid']) ? 0 : validInt($_REQUEST['mid']);
if ( !($mid and canEdit('Monitors', $mid)) ) {
$view = 'error';
return;
}
$mid = validInt($_REQUEST['mid']);
$zid = (!empty($_REQUEST['zid'])) ? validInt($_REQUEST['zid']) : 0;
$scale = SCALE_BASE;

View File

@ -18,12 +18,12 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
if ( !canView('Monitors') ) {
$mid = empty($_REQUEST['mid']) ? 0 : validInt($_REQUEST['mid']);
if ( !($mid and canEdit('Monitors', $mid)) ) {
$view = 'error';
return;
}
$mid = validInt($_REQUEST['mid']);
$monitor = new ZM\Monitor($mid);
# ViewWidth() and ViewHeight() are already rotated
$minX = 0;