From b56a976d7adbad13abe99a8b5d64aff024ce7001 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 5 Oct 2017 10:46:04 -0400 Subject: [PATCH] fixes to montage review and cleanup in group filtering/editing --- web/includes/Group.php | 56 ++++++++++- web/includes/functions.php | 8 +- web/skins/classic/views/console.php | 70 ++++--------- web/skins/classic/views/group.php | 5 +- web/skins/classic/views/js/montagereview.js | 26 +++-- web/skins/classic/views/montage.php | 106 +++++++------------- web/skins/classic/views/montagereview.php | 74 ++++---------- 7 files changed, 146 insertions(+), 199 deletions(-) diff --git a/web/includes/Group.php b/web/includes/Group.php index 24d154504..329df4c20 100644 --- a/web/includes/Group.php +++ b/web/includes/Group.php @@ -119,6 +119,60 @@ public $defaults = array( } return $this->{'depth'}; } // end public function depth -} # end class Group + public static function get_group_dropdowns() { + # This will end up with the group_id of the deepest selection + $group_id = 0; + $depth = 0; + $groups = array(); + $parent_group_ids = null; + while(1) { + $Groups = Group::find_all( array('ParentId'=>$parent_group_ids) ); + if ( ! count( $Groups ) ) + break; + + $parent_group_ids = array(); + $selected_group_id = 0; + if ( isset($_REQUEST['group'.$depth]) and $_REQUEST['group'.$depth] > 0 ) { + $selected_group_id = $group_id = $_REQUEST['group'.$depth]; + } else if ( isset($_COOKIE['zmGroup'.$depth] ) and $_COOKIE['zmGroup'.$depth] > 0 ) { + $selected_group_id = $group_id = $_COOKIE['zmGroup'.$depth]; + } + + foreach ( $Groups as $Group ) { + if ( ! isset( $groups[$depth] ) ) { + $groups[$depth] = array(0=>'All'); + } + $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, "changeGroup(this,$depth);" ); + if ( ! count($parent_group_ids) ) break; + $depth += 1; + } + + return $group_id; + } # end public static function get_group_dropdowns() + + public static function get_group_sql( $group_id ) { + $groupSql = ''; + if ( $group_id ) { + if ( $group = dbFetchOne( 'SELECT MonitorIds FROM Groups WHERE Id=?', NULL, array($group_id) ) ) { + $groupIds = array(); + if ( $group['MonitorIds'] ) + $groupIds = explode( ',', $group['MonitorIds'] ); + + Warning("Group ids" . implode(',',$groupIds) ); + foreach ( dbFetchAll( 'SELECT MonitorIds FROM Groups WHERE ParentId = ?', NULL, array($group_id) ) as $group ) + if ( $group['MonitorIds'] ) + $groupIds = array_merge( $groupIds, explode( ',', $group['MonitorIds'] ) ); + } + Warning("Group ids" . implode(',',$groupIds) ); + $groupSql = " find_in_set( Id, '".implode( ',', $groupIds )."' )"; + } + return $groupSql; + } # end public static function get_group_sql( $group_id ) +} # end class Group ?> diff --git a/web/includes/functions.php b/web/includes/functions.php index acef0c603..6b8ee47dc 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -556,10 +556,10 @@ function htmlSelect( $name, $contents, $values, $behaviours=false ) { } $html = " to @@ -254,15 +216,15 @@ xhtmlHeaders(__FILE__, translate('MontageReview') ); fps
- - - - - - + + + + + + - +