From 8abb8a925957a075dde00616508a81bbc7e29132 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 12 Oct 2017 07:32:48 -0700 Subject: [PATCH] add Type to Storage --- db/zm_create.sql.in | 1 + version | 2 +- web/includes/Event.php | 2 +- web/includes/Group.php | 28 +++++++++++++++++++++++ web/includes/Storage.php | 3 ++- web/skins/classic/views/monitor.php | 2 +- web/skins/classic/views/montagereview.php | 4 ++-- 7 files changed, 36 insertions(+), 6 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 1b45b1216..9b8e0c3f1 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -593,6 +593,7 @@ CREATE TABLE `Storage` ( `Id` smallint(5) unsigned NOT NULL auto_increment, `Path` varchar(64) NOT NULL default '', `Name` varchar(64) NOT NULL default '', + `Type` enum('local','s3fs') NOT NULL default 'local', PRIMARY KEY (`Id`) ) ENGINE=@ZM_MYSQL_ENGINE@; diff --git a/version b/version index c00278b9b..a5923108d 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.31.8 +1.31.9 diff --git a/web/includes/Event.php b/web/includes/Event.php index b2137ae42..3a504145c 100644 --- a/web/includes/Event.php +++ b/web/includes/Event.php @@ -37,7 +37,7 @@ class Event { if ( $new ) { $this->{'Storage'} = $new; } - if ( ! ( array_key_exists( 'Storage', $this ) or $this->{'Storage'} ) ) { + if ( ! ( array_key_exists( 'Storage', $this ) and $this->{'Storage'} ) ) { $this->{'Storage'} = new Storage( isset($this->{'StorageId'}) ? $this->{'StorageId'} : NULL ); } return $this->{'Storage'}; diff --git a/web/includes/Group.php b/web/includes/Group.php index 48c5e00f6..7db8486d2 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -181,5 +181,33 @@ public $defaults = array( return $groupSql; } # end public static function get_group_sql( $group_id ) + public static function get_monitors_dropdown( $options = null ) { + $monitor_id = 0; + if ( isset( $_REQUEST['monitor_id'] ) ) { + $monitor_id = $_REQUEST['monitor_id']; + } else if ( isset($_COOKIE['zmMonitorId']) ) { + $monitor_id = $_COOKIE['zmMonitorId']; + } + $sql = 'SELECT * FROM Monitors'; + if ( $options ) { + $sql .= ' WHERE '. implode(' AND ', array( + ( isset($options['groupSql']) ? $options['groupSql']:'') + ) ).' ORDER BY Sequence ASC'; + } + $monitors_dropdown = array(''=>'All'); + + foreach ( dbFetchAll( $sql ) as $monitor ) { + if ( !visibleMonitor( $monitor['Id'] ) ) { + continue; + } + $monitors_dropdown[$monitor['Id']] = $monitor['Name']; + } + + echo htmlSelect( 'monitor_id', $monitors_dropdown, $monitor_id, array('onchange'=>'changeMonitor(this);') ); + return $monitor_id; +} + } # end class Group + + ?> diff --git a/web/includes/Storage.php b/web/includes/Storage.php index c31b5b2f1..97672173e 100644 --- a/web/includes/Storage.php +++ b/web/includes/Storage.php @@ -29,6 +29,7 @@ class Storage { } else { $this->{'Name'} = ''; $this->{'Path'} = ''; + $this->{'Type'} = 'local'; } } @@ -105,7 +106,7 @@ class Storage { # This isn't a function like this in php, so we have to add up the space used in each event. if ( ! array_key_exists( 'disk_used_space', $this ) ) { $used = 0; - if ( $this->{'type'} == 's3' ) { + if ( $this->{'Type'} == 's3fs' ) { foreach ( Event::find_all( array( 'StorageId'=>$this->Id() ) ) as $Event ) { $Event->Storage( $this ); // Prevent further db hit $used += $Event->DiskSpace(); diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 0e92476e6..42891ac23 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -672,7 +672,7 @@ switch ( $tab ) { case 'general' : { ?> - + 'None'); diff --git a/web/skins/classic/views/montagereview.php b/web/skins/classic/views/montagereview.php index ec8443a41..6dd8c8a2b 100644 --- a/web/skins/classic/views/montagereview.php +++ b/web/skins/classic/views/montagereview.php @@ -114,7 +114,7 @@ if ( ! empty( $user['MonitorIds'] ) ) { $frameSql .= ' AND E.MonitorId IN ('.$user['MonitorIds'].')'; } if ( $monitor_id ) { - $monitorsSql .= ' AND Id='.$monitor_id; + $monitorsSql .= ' AND Id='.$monitor_id; $eventsSql .= ' AND M.Id='.$monitor_id; $frameSql .= ' AND E.MonitorId='.$monitor_id; } @@ -214,7 +214,7 @@ xhtmlHeaders(__FILE__, translate('MontageReview') ); - 'changeMonitor(this);') ); ?> + $groupSql) ); ?>
to