diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 8f4b5c2a3..4faa377f4 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -480,6 +480,8 @@ Debug(2,"last_write_index(%d), last_write_time(%d)", shared_data->last_write_ind ( shared_data->last_write_index == (unsigned int)image_buffer_count ) && ( shared_data->last_write_time == 0) + && + ( !zm_terminate ) ) { Warning( "Waiting for capture daemon" ); sleep( 1 ); diff --git a/web/includes/Group.php b/web/includes/Group.php index 9d6d058bb..543665655 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -135,6 +135,61 @@ public $defaults = array( return $this->{'MonitorIds'}; } + public static function get_group_dropdown() { + + session_start(); + $selected_group_id = 0; + if ( isset($_REQUEST['groups']) ) { + $selected_group_id = $group_id = $_SESSION['groups'] = $_REQUEST['groups']; + } else if ( isset( $_SESSION['groups'] ) ) { + $selected_group_id = $group_id = $_SESSION['groups']; + } else if ( isset($_REQUEST['filtering']) ) { + unset($_SESSION['groups']); + } + session_write_close(); + + $Groups = array(); + foreach ( Group::find_all( ) as $Group ) { + $Groups[$Group->Id()] = $Group; + } + +# This array is indexed by parent_id +global $children; + $children = array(); + + foreach ( $Groups as $id=>$Group ) { + if ( $Group->ParentId() != null ) { + if ( ! isset( $children[$Group->ParentId()] ) ) + $children[$Group->ParentId()] = array(); + $children[$Group->ParentId()][] = $Group; + } + } + + function get_options( $Group ) { + global $children; + $options = array( $Group->Id() => str_repeat('   ', $Group->depth() ) . $Group->Name() ); + if ( isset($children[$Group->Id()]) ) { + foreach ( $children[$Group->Id()] as $child ) { + $options += get_options( $child ); + } + } + return $options; + } + $group_options = array(); + foreach ( $Groups as $id=>$Group ) { + if ( ! $Group->ParentId() ) { + $group_options += get_options( $Group ); + } + } + return htmlSelect( 'Group[]', $group_options, isset($_SESSION['Group'])?$_SESSION['Group']:null, array( + 'onchange' => 'this.form.submit();', + 'class'=>'chosen', + 'multiple'=>'multiple', + 'data-placeholder'=>'All', + ) ); + + } # end public static function get_group_dropdown + public static function get_group_dropdowns() { # This will end up with the group_id of the deepest selection $group_id = 0; @@ -142,6 +197,8 @@ public $defaults = array( $groups = array(); $parent_group_ids = null; session_start(); + + $group_options = array(0=>'All'); while(1) { $Groups = Group::find_all( array('ParentId'=>$parent_group_ids) ); if ( ! count( $Groups ) ) @@ -161,15 +218,17 @@ public $defaults = array( if ( ! isset( $groups[$depth] ) ) { $groups[$depth] = array(0=>'All'); } +$group_options[$Group->Id()] = str_repeat( ' ', $depth ) . $Group->Name(); $groups[$depth][$Group->Id()] = $Group->Name(); if ( $selected_group_id and ( $selected_group_id == $Group->Id() ) ) $parent_group_ids[] = $Group->Id(); } - echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" ); + //echo htmlSelect( 'group'.$depth, $groups[$depth], $selected_group_id, "this.form.submit();" ); if ( ! count($parent_group_ids) ) break; $depth += 1; } + echo htmlSelect( 'groups', $group_options, $selected_group_id, 'this.form.submit();' ); session_write_close(); return $group_id; @@ -179,9 +238,17 @@ public $defaults = array( public static function get_group_sql( $group_id ) { $groupSql = ''; if ( $group_id ) { - $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) ); + if ( is_array( $group_id ) ) { + $group_id_sql_part = ' IN ('.implode(',', array_map(function(){return '?';}, $group_id ) ).')'; - $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) ); + $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId'.$group_id_sql_part, 'MonitorId', $group_id ); + + $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId'.$group_id_sql_part.')', 'MonitorId', $group_id ) ); + } else { + $MonitorIds = dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId=?', 'MonitorId', array($group_id) ); + + $MonitorIds = array_merge( $MonitorIds, dbFetchAll( 'SELECT MonitorId FROM Groups_Monitors WHERE GroupId IN (SELECT Id FROM Groups WHERE ParentId = ?)', 'MonitorId', array($group_id) ) ); + } $groupSql = " find_in_set( Id, '".implode( ',', $MonitorIds )."' )"; } return $groupSql; diff --git a/web/includes/functions.php b/web/includes/functions.php index 87bce296a..a05bfe6b2 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -636,10 +636,10 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { { if ( is_array( $newValues[$key] ) ) { if ( join(',',$newValues[$key]) != $values[$key] ) { - $changes[$key] = "$key = ".dbEscape(join(',',$newValues[$key])); + $changes[$key] = "`$key` = ".dbEscape(join(',',$newValues[$key])); } } elseif ( $values[$key] ) { - $changes[$key] = "$key = ''"; + $changes[$key] = "`$key` = ''"; } break; } @@ -696,9 +696,9 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) { { if ( !isset($values[$key]) || ($values[$key] != $value) ) { if ( ! isset($value) || $value == '' ) { - $changes[$key] = "$key = NULL"; + $changes[$key] = "`$key` = NULL"; } else { - $changes[$key] = $key . ' = '.dbEscape(trim($value)); + $changes[$key] = "`$key` = ".dbEscape(trim($value)); } } break; diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index b6f0e7455..993441cdf 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -82,9 +82,11 @@ echo output_link_if_exists( array( '/js/dateTimePicker/jquery-ui-timepicker-addon.css', '/js/jquery-ui-structure.css', '/css/'.$css.'/jquery-ui-theme.css', - '/js/chosen/chosen.min.css', ) ); +?> + +Id()] = $S; } session_start(); -foreach ( array('ServerId','StorageId','Status','MonitorId') as $var ) { +foreach ( array('Group', 'ServerId','StorageId','Status','MonitorId') as $var ) { if ( isset( $_REQUEST[$var] ) ) { if ( $_REQUEST[$var] != '' ) { $_SESSION[$var] = $_REQUEST[$var]; @@ -49,7 +49,8 @@ foreach ( $storage_areas as $S ) { diff --git a/web/skins/classic/views/group.php b/web/skins/classic/views/group.php index 11ea093ed..df9ea36d4 100644 --- a/web/skins/classic/views/group.php +++ b/web/skins/classic/views/group.php @@ -92,7 +92,8 @@ if ( $newGroup->Id() ) $sql = 'SELECT Id,Name from Groups'.(count($kids)?' WHERE Id NOT IN ('.implode(',',array_map(function(){return '?';}, $kids )).')' : '').' ORDER BY Name'; $options = array(''=>'None'); foreach ( dbFetchAll( $sql, null, $kids ) as $option ) { - $options[$option['Id']] = $option['Name']; + + $options[$option['Id']] = str_repeat('  ', $Groups[$option['Id']]->depth() ) . $option['Name']; } echo htmlSelect( 'newGroup[ParentId]', $options, $newGroup->ParentId(), array('onchange'=>'configureButtons(this);' )); ?> diff --git a/web/skins/classic/views/groups.php b/web/skins/classic/views/groups.php index 7301020b9..f3ea754e2 100644 --- a/web/skins/classic/views/groups.php +++ b/web/skins/classic/views/groups.php @@ -18,7 +18,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView( 'Groups' ) ) { +if ( !canView('Groups') ) { $view = 'error'; return; } @@ -64,8 +64,7 @@ function group_line( $Group ) { global $children; global $max_depth; $html = ''; - for ( $i = 1; $i<$Group->depth(); $i+=1 ) - $html .= ' '; + $html .= str_repeat( ' ', $Group->depth() ); $html .= ''; if ( canEdit('Groups') ) { $html .= ''. validHtmlStr($Group->Id() . ' ' . $Group->Name()).''; diff --git a/web/skins/classic/views/js/montagereview.js b/web/skins/classic/views/js/montagereview.js index e1f854f66..7a180c9ef 100644 --- a/web/skins/classic/views/js/montagereview.js +++ b/web/skins/classic/views/js/montagereview.js @@ -526,7 +526,7 @@ function clicknav(minSecs,maxSecs,live) {// we use the current time if we can if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1 zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2); - var uri = "?view=" + currentView + '&fit='+(fitMode==1?'1':'0') + groupStr + minStr + maxStr + currentStr + intervalStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; + var uri = "?view=" + currentView + '&fit='+(fitMode==1?'1':'0') + minStr + maxStr + currentStr + intervalStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; window.location = uri; } // end function clicknav @@ -745,7 +745,7 @@ function changeDateTime(e) { if ( monitorZoomScale[monitorPtr[i]] < 0.99 || monitorZoomScale[monitorPtr[i]] > 1.01 ) // allow for some up/down changes and just treat as 1 of almost 1 zoomStr += "&z" + monitorPtr[i].toString() + "=" + monitorZoomScale[monitorPtr[i]].toFixed(2); - var uri = "?view=" + currentView + fitStr + groupStr + minStr + maxStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; + var uri = "?view=" + currentView + fitStr + minStr + maxStr + liveStr + zoomStr + "&scale=" + $j("#scaleslider")[0].value + "&speed=" + speeds[$j("#speedslider")[0].value]; window.location = uri; } diff --git a/web/skins/classic/views/js/montagereview.js.php b/web/skins/classic/views/js/montagereview.js.php index 19089a315..981724a57 100644 --- a/web/skins/classic/views/js/montagereview.js.php +++ b/web/skins/classic/views/js/montagereview.js.php @@ -27,7 +27,6 @@ var eStorageId = []; var eStartSecs = []; var eEndSecs = []; var eventFrames = []; // this is going to presume all frames equal durationlength -var groupStr=;