From f83a04ab041224f568e6b13d9271eb2f3334c48a Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 2 Feb 2009 06:31:39 +0000 Subject: [PATCH] - Fixup the judge reports for the new user system --- admin/reports_judges.inc.php | 46 +++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/admin/reports_judges.inc.php b/admin/reports_judges.inc.php index 4173a545..0d7d933b 100644 --- a/admin/reports_judges.inc.php +++ b/admin/reports_judges.inc.php @@ -21,6 +21,17 @@ Boston, MA 02111-1307, USA. */ + +/* Take the language array in users_judge, unserialize it, and join it + * with a space */ +function report_judges_languages(&$report, $text) +{ + $l = unserialize($text); + return join(' ', $l); +} + + + /* Components: languages, teams */ $report_judges_fields = array( @@ -99,19 +110,20 @@ $report_judges_fields = array( 'table' => 'users.organization'), 'languages' => array( - 'name' => 'Judge -- Languages (REQUIRES MySQL 5.0)', + 'name' => 'Judge -- Languages', 'header' => 'Lang', 'width' => 0.75, - 'table' => "GROUP_CONCAT(judges_languages.languages_lang ORDER BY judges_languages.languages_lang SEPARATOR ' ')", - 'group_by' => array('judges.id'), - 'components' => array('languages')), + 'table' => 'users_judge.languages', + 'exec_function' => 'report_judges_languages', + 'components' => array('users_judge')), 'complete' => array( 'name' => 'Judge -- Registration Complete', 'header' => 'Cmpl', 'width' => 0.4, - 'table' => 'judges.complete', - 'value_map' => array ('no' => 'No', 'yes' => 'Yes')), + 'table' => 'users_judge.judge_complete', + 'value_map' => array ('no' => 'No', 'yes' => 'Yes'), + 'components' => array('users_judge')), 'year' => array( 'name' => 'Judge -- Year', @@ -174,7 +186,7 @@ $report_judges_fields = array( 'header' => 'Student(s)', 'width' => 3.0, 'table' => "GROUP_CONCAT(students.firstname, ' ', students.lastname ORDER BY students.lastname SEPARATOR ', ')", - 'group_by' => array('judges.id','judges_teams_timeslots_projects_link.id'), + 'group_by' => array('users.id','judges_teams_timeslots_projects_link.id'), 'components' => array('teams', 'projects', 'students')), 'project_timeslot_start' => array( @@ -220,17 +232,14 @@ $report_judges_fields = array( $fields = $report_judges_fields; $year = $report['year']; - /* For now languages is a module, doesn't duplicate rows, but it requries mysql 5 for - * a GROUP_CONCAT */ - $languages_from = ''; - if(in_array('languages', $components)) { - $languages_from = 'LEFT JOIN judges_languages ON judges_languages.judges_id=judges.id'; + if(in_array('users_judge', $components)) { + $uj_from = 'LEFT JOIN users_judge ON users_judge.users_id=users.id'; } $teams_from = ''; $teams_where = ''; if(in_array('teams', $components)) { - $teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.judges_id=judges.id + $teams_from = "LEFT JOIN judges_teams_link ON judges_teams_link.users_id=users.id LEFT JOIN judges_teams ON judges_teams.id=judges_teams_link.judges_teams_id"; $teams_where = "AND judges_teams_link.year='$year' AND judges_teams.year='$year'"; @@ -255,22 +264,21 @@ $report_judges_fields = array( } /* Search the report for a filter based on judge year */ - $year_where = "judges_years.year='$year'"; + $year_where = "AND users.year='$year'"; foreach($report['filter'] as $d) { if($d['field'] == 'year') { - /* Don't interally filter on year, we'll do it - * externally */ - $year_where = '1'; + /* Don't interally filter on year, we'll do it externally */ + $year_where = ''; } } $q = " FROM users - LEFT JOIN judges_years ON judges_years.judges_id = judges.id - $languages_from $teams_from $projects_from $students_from + $uj_from WHERE + users.types LIKE '%judge%' $year_where $teams_where $projects_where