diff --git a/src/zm_event.cpp b/src/zm_event.cpp index aa1a616d0..303745277 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -442,7 +442,10 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st static char event_file[PATH_MAX]; snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames ); - if ( monitor->GetOptSaveJPEGs() & 4 ) { + if ( monitor->GetOptSaveJPEGs() & 1 ) { + Debug( 1, "Writing pre-capture frame %d", frames ); + WriteFrameImage( images[i], *(timestamps[i]), event_file ); + } else { //If this is the first frame, we should add a thumbnail to the event directory // ICON: We are working through the pre-event frames so this snapshot won't // neccessarily be of the motion. But some events are less than 10 frames, @@ -453,10 +456,6 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st WriteFrameImage( images[i], *(timestamps[i]), snapshot_file ); } } - if ( monitor->GetOptSaveJPEGs() & 1 ) { - Debug( 1, "Writing pre-capture frame %d", frames ); - WriteFrameImage( images[i], *(timestamps[i]), event_file ); - } if ( videowriter != NULL ) { WriteFrameVideo( images[i], *(timestamps[i]), videowriter ); } @@ -494,20 +493,18 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * static char event_file[PATH_MAX]; snprintf( event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames ); - if ( monitor->GetOptSaveJPEGs() & 4 ) { - // Only snapshots - //If this is the first frame, we should add a thumbnail to the event directory - if ( frames == 10 ) { - char snapshot_file[PATH_MAX]; - snprintf( snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path ); - WriteFrameImage( image, timestamp, snapshot_file ); - } - } if ( monitor->GetOptSaveJPEGs() & 1 ) { Debug( 1, "Writing capture frame %d to %s", frames, event_file ); if ( ! WriteFrameImage( image, timestamp, event_file ) ) { Error("Failed to write frame image"); } + } else { + //If this is the first frame, we should add a thumbnail to the event directory + if ( frames == 1 ) { + char snapshot_file[PATH_MAX]; + snprintf( snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path ); + WriteFrameImage( image, timestamp, snapshot_file ); + } } if ( videowriter != NULL ) { Debug(3, "Writing video"); diff --git a/web/includes/Server.php b/web/includes/Server.php index fa892f8d9..a6d2b06a5 100644 --- a/web/includes/Server.php +++ b/web/includes/Server.php @@ -23,15 +23,39 @@ class Server { $this->{'Hostname'} = ''; } } - public static function find_all() { - $servers = array(); - $result = dbQuery( 'SELECT * FROM Servers ORDER BY Name'); - $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server' ); - foreach ( $results as $row => $server_obj ) { - $servers[] = $server_obj; - } - return $servers; - } + public static function find_all( $parameters = null, $options = null ) { + $filters = array(); + $sql = 'SELECT * FROM Servers '; + $values = array(); + + if ( $parameters ) { + $fields = array(); + $sql .= 'WHERE '; + foreach ( $parameters as $field => $value ) { + if ( $value == null ) { + $fields[] = $field.' IS NULL'; + } else if ( is_array( $value ) ) { + $func = function(){return '?';}; + $fields[] = $field.' IN ('.implode(',', array_map( $func, $value ) ). ')'; + $values += $value; + + } else { + $fields[] = $field.'=?'; + $values[] = $value; + } + } + $sql .= implode(' AND ', $fields ); + } + if ( $options and isset($options['order']) ) { + $sql .= ' ORDER BY ' . $options['order']; + } + $result = dbQuery($sql, $values); + $results = $result->fetchALL(PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE, 'Server'); + foreach ( $results as $row => $obj ) { + $filters[] = $obj; + } + return $filters; + } public function Url() { if ( $this->Id() ) { diff --git a/web/skins/classic/views/_monitor_filters.php b/web/skins/classic/views/_monitor_filters.php index 6cbcde0dc..eb58fccf6 100644 --- a/web/skins/classic/views/_monitor_filters.php +++ b/web/skins/classic/views/_monitor_filters.php @@ -18,7 +18,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -$servers = Server::find_all(); +$servers = Server::find_all( null, array('order'=>'lower(Name)')); $ServersById = array(); foreach ( $servers as $S ) { $ServersById[$S->Id()] = $S; diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 7e240092b..f3818ca16 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -463,7 +463,6 @@ $savejpegopts = array( 'Frames only' => 1, 'Analysis images only (if available)' => 2, 'Frames + Analysis images (if available)' => 3, - 'Snapshot Only' => 4 ); $videowriteropts = array( diff --git a/web/skins/classic/views/storage.php b/web/skins/classic/views/storage.php index c5962ba01..8768e445c 100644 --- a/web/skins/classic/views/storage.php +++ b/web/skins/classic/views/storage.php @@ -19,20 +19,20 @@ // if ( !canEdit( 'System' ) ) { - $view = 'error'; - return; + $view = 'error'; + return; } if ( $_REQUEST['id'] ) { - if ( !($newStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, ARRAY($_REQUEST['id'])) ) ) { - $view = 'error'; - return; + if ( !($newStorage = dbFetchOne('SELECT * FROM Storage WHERE Id=?', NULL, ARRAY($_REQUEST['id'])) ) ) { + $view = 'error'; + return; $newStorage['ServerId'] = ''; - } + } } else { - $newStorage = array(); - $newStorage['Name'] = translate('NewStorage'); - $newStorage['Path'] = ''; + $newStorage = array(); + $newStorage['Name'] = translate('NewStorage'); + $newStorage['Path'] = ''; $newStorage['Type'] = 'local'; $newStorage['Scheme'] = 'Medium'; } @@ -44,7 +44,7 @@ $scheme_options = array( 'Shallow' => translate('Shallow'), ); -$servers = Server::find_all(); +$servers = Server::find_all( null, array('order'=>'lower(Name)') ); $ServersById = array(); foreach ( $servers as $S ) { $ServersById[$S->Id()] = $S; @@ -75,7 +75,7 @@ xhtmlHeaders(__FILE__, translate('Storage')." - ".$newStorage['Name'] );