From cffdfeaee2265b5abef768e1b2b0a0dd2e672552 Mon Sep 17 00:00:00 2001 From: geoffhumphrey Date: Fri, 18 Oct 2024 08:56:29 -0600 Subject: [PATCH] Finalize Version 2.7.2 - Partially Address #1580 --- admin/judging_locations.admin.php | 2 +- admin/participants.admin.php | 107 ++++++++++++++----------- includes/db/brewer.db.php | 28 +++---- includes/process.inc.php | 2 +- includes/process/process_users.inc.php | 11 ++- lib/common.lib.php | 4 +- sections/user.sec.php | 2 +- 7 files changed, 84 insertions(+), 72 deletions(-) diff --git a/admin/judging_locations.admin.php b/admin/judging_locations.admin.php index a9dc3e0f..c8dad704 100644 --- a/admin/judging_locations.admin.php +++ b/admin/judging_locations.admin.php @@ -327,7 +327,7 @@ } - if ($none_selected == 0) { + if ((isset($none_selected)) && ($none_selected == 0)) { if ($filter != "staff") $output .= " None specified."; } diff --git a/admin/participants.admin.php b/admin/participants.admin.php index 1a4fcd42..444f4b49 100644 --- a/admin/participants.admin.php +++ b/admin/participants.admin.php @@ -205,9 +205,6 @@ $judge_entries = ""; $brewer_assignment = ""; $user_info = ""; - - $user_info = user_info($row_brewer['uid']); - $user_info = explode("^",$user_info); if ($_SESSION['brewerCountry'] == "United States") $us_phone = TRUE; else $us_phone = FALSE; @@ -248,7 +245,7 @@ if ($row_brewer['brewerEmail'] != $_SESSION['loginUsername']) $output_datatables_other_link = build_action_link("fa-lock",$base_url,"admin","make_admin","default","default",$row_brewer['uid'],"default","default",0,"Change ".$brewer_tooltip_display_name."’s User Level"); else $output_datatables_other_link = ""; - $output_datatables_other_link2 = build_action_link("fa-user",$base_url,"user","default","username","admin",$row_brewer['uid'],"default","default",0,"Change ".$brewer_tooltip_display_name."’s email address"); + $output_datatables_other_link2 = build_action_link("fa-user",$base_url,"user","default","username","admin",$row_brewer['user_id'],"default","default",0,"Change ".$brewer_tooltip_display_name."’s email address"); } @@ -277,7 +274,7 @@ } if ($_SESSION['userLevel'] == 0) { - $output_datatables_change_pwd = build_action_link("fa-key",$base_url,"admin","change_user_password","edit","default",$row_brewer['uid'],"default","default",0,"Change ".$brewer_tooltip_display_name."’s password"); + $output_datatables_change_pwd = build_action_link("fa-key",$base_url,"admin","change_user_password","edit","default",$row_brewer['user_id'],"default","default",0,"Change ".$brewer_tooltip_display_name."’s password"); } else $output_datatables_change_pwd = ""; @@ -299,7 +296,7 @@ if ($filter == "with_entries") { unset($entries); - + unset($judging_nums); $output_datatables_body .= ""; if ($pro_edition == 1) $output_datatables_body .= "".$row_brewer['brewerBreweryName'].""; else { @@ -318,7 +315,16 @@ $brewer_entries = implode(",",$entries); - $output_datatables_body .= " ".str_replace(",",", ",$brewer_entries).""; + $explodies = explode(",",$row_brewer['JudgingNums']); + + foreach ($explodies as $judging_number) { + $judging_number = sprintf("%06s",$judging_number); + $judging_nums[] = $judging_number; + } + + $brewer_entries_judging_nums = implode(",",$judging_nums); + + $output_datatables_body .= "Entry Numbers: ".str_replace(",",", ",$brewer_entries)."
Judging Numbers: ".str_replace(",",", ",$brewer_entries_judging_nums).""; if ($action != "print") $output_datatables_body .= "".$output_datatables_actions.""; $output_datatables_body .= ""; @@ -326,49 +332,54 @@ else { - $table_assign_judge = table_assignments($user_info[0],"J",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1); - $table_assign_judge = str_replace(", ","
",$table_assign_judge); - - $table_assign_steward = table_assignments($user_info[0],"S",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1); - $table_assign_steward = str_replace(", ","
",$table_assign_steward); - - $judge_entries = judge_entries($row_brewer['uid'],1); - if ($filter == "judges") $locations = $row_brewer['brewerJudgeLocation']; if ($filter == "stewards") $locations = $row_brewer['brewerStewardLocation']; if ((!empty($brewer_assignment) && (!$archive_display))) { + + $table_assign_judge = table_assignments($row_brewer['user_id'],"J",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1); + $table_assign_judge = str_replace(", ","
",$table_assign_judge); - // Build assignment modal for participants - unset($assignment_modal_body); - if ((strpos($brewer_assignment,"Judge") !== false) || (strpos($brewer_assignment,"Steward") !== false) ) { + $table_assign_steward = table_assignments($row_brewer['user_id'],"S",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1); + $table_assign_steward = str_replace(", ","
",$table_assign_steward); + + $judge_entries = judge_entries($row_brewer['uid'],1); - if (strpos($brewer_assignment,"Judge") !== false) { - if (!empty($table_assign_judge)) $assignment_modal_body = "

".$row_brewer['brewerFirstName']." is assigned as a judge to table(s): ".$table_assign_judge."

"; - else $assignment_modal_body = "

".$row_brewer['brewerFirstName']." has been added to the judge pool, but has not been assigned to a table yet.

"; - } - if (strpos($brewer_assignment,"Steward") !== false) { - if (!empty($table_assign_steward)) $assignment_modal_body = "

".$row_brewer['brewerFirstName']." is assigned as a steward to table(s): ".$table_assign_steward."

"; - else $assignment_modal_body = "

".$row_brewer['brewerFirstName']." has been added to the steward pool, but has not been assigned to a table yet.

"; + if (($filter != "judges") && ($filter != "stewards")) { + + // Build assignment modal for participants + unset($assignment_modal_body); + if ((strpos($brewer_assignment,"Judge") !== false) || (strpos($brewer_assignment,"Steward") !== false) ) { + + if (strpos($brewer_assignment,"Judge") !== false) { + if (!empty($table_assign_judge)) $assignment_modal_body = "

".$row_brewer['brewerFirstName']." is assigned as a judge to table(s):
".$table_assign_judge."

"; + else $assignment_modal_body = "

".$row_brewer['brewerFirstName']." has been added to the judge pool, but has not been assigned to a table yet.

"; + } + if (strpos($brewer_assignment,"Steward") !== false) { + if (!empty($table_assign_steward)) $assignment_modal_body = "

".$row_brewer['brewerFirstName']." is assigned as a steward to table(s):
".$table_assign_steward."

"; + else $assignment_modal_body = "

".$row_brewer['brewerFirstName']." has been added to the steward pool, but has not been assigned to a table yet.

"; + } + if (!empty($judge_entries)) $assignment_modal_body .= "

Has entries in: ".$judge_entries."

"; + $output_assignment_modals .= "
\n"; + $output_assignment_modals .= "\t
\n"; + $output_assignment_modals .= "\t\t
\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t\t\t\n"; + $output_assignment_modals .= "\t\t\t\t

Assignment(s) for ".$brewer_tooltip_display_name."

\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t\t\t".$assignment_modal_body."\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t\t\t\n"; + $output_assignment_modals .= "\t\t\t
\n"; + $output_assignment_modals .= "\t\t
\n"; + $output_assignment_modals .= "\t
\n"; + $output_assignment_modals .= "
\n"; } - if (!empty($judge_entries)) $assignment_modal_body .= "

Has entries in: ".$judge_entries."

"; - $output_assignment_modals .= "
\n"; - $output_assignment_modals .= "\t
\n"; - $output_assignment_modals .= "\t\t
\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t\t\t\n"; - $output_assignment_modals .= "\t\t\t\t

Assignment(s) for ".$brewer_tooltip_display_name."

\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t\t\t".$assignment_modal_body."\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t\t\t\n"; - $output_assignment_modals .= "\t\t\t
\n"; - $output_assignment_modals .= "\t\t
\n"; - $output_assignment_modals .= "\t
\n"; - $output_assignment_modals .= "
\n"; + } + } $output_datatables_body .= ""; @@ -376,16 +387,16 @@ $output_datatables_body .= ""; $output_datatables_body .= ""; $output_datatables_body .= $row_brewer['brewerLastName'].", ".$row_brewer['brewerFirstName']; - if (($dbTable == "default") && ($user_info[1] == 0)) $output_datatables_body .= " "; - elseif (($dbTable == "default") && ($user_info[1] == 1)) $output_datatables_body .= " "; + if (($dbTable == "default") && ($row_brewer['userLevel'] == 0)) $output_datatables_body .= " "; + elseif (($dbTable == "default") && ($row_brewer['userLevel'] == 1)) $output_datatables_body .= " "; if ($action != "print") $output_datatables_body .= "
".$row_brewer['brewerCity'].", ".$row_brewer['brewerState'].""; $output_datatables_body .= ""; $output_datatables_body .= ""; - if (($dbTable == "default") && ($user_info[1] == 0)) $output_datatables_body .= "Top-Level Admin"; - elseif (($dbTable == "default") && ($user_info[1] == 1)) $output_datatables_body .= "Admin"; + if (($dbTable == "default") && ($row_brewer['userLevel'] == 0)) $output_datatables_body .= "Top-Level Admin"; + elseif (($dbTable == "default") && ($row_brewer['userLevel'] == 1)) $output_datatables_body .= "Admin"; else $output_datatables_body .= "Participant"; - if (($dbTable == "default") && ($user_info[2] == 0)) $output_datatables_body .= " "; + if (($dbTable == "default") && ($row_brewer['userLevel'] == 0)) $output_datatables_body .= " "; else $output_datatables_body .= " "; $output_datatables_body .= ""; @@ -456,7 +467,7 @@ if (!empty($brewer_assignment)) { - if ((!$archive_display) && ((strpos($brewer_assignment,"Judge") !== false) || (strpos($brewer_assignment,"Steward") !== false))) { + if (((!$archive_display) && ((strpos($brewer_assignment,"Judge") !== false) || (strpos($brewer_assignment,"Steward") !== false))) && ($filter != "judges") && ($filter != "stewards")) { $output_datatables_body .= ""; } else { diff --git a/includes/db/brewer.db.php b/includes/db/brewer.db.php index fcff8e20..89115d67 100644 --- a/includes/db/brewer.db.php +++ b/includes/db/brewer.db.php @@ -40,27 +40,22 @@ } elseif ($section == "pay") { - $query_brewer = sprintf("SELECT * FROM $brewer_db_table WHERE uid = '%s'", $_SESSION['user_id']); + $query_brewer = sprintf("SELECT * FROM $brewer_db_table WHERE uid = '%s'", $_SESSION['user_id']); $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); $row_brewer = mysqli_fetch_assoc($brewer); $totalRows_brewer = mysqli_num_rows($brewer); } // Viewing all participants in current comp DB query - // @single elseif ((($section == "admin") && ($go == "participants") && ($filter == "default") && ($dbTable == "default")) || ($section == "participant_summary") || ($section == "particpant-entries")) { - if (SINGLE) $query_brewer = sprintf("SELECT * FROM %s WHERE FIND_IN_SET('%s',brewerCompParticipant) > 0", $brewer_db_table, $_SESSION['comp_id']); - else $query_brewer = sprintf("SELECT * FROM %s ORDER BY brewerLastName", $brewer_db_table); + $query_brewer = sprintf("SELECT a.*, b.id AS user_id, b.user_name, b.userLevel, b.userAdminObfuscate FROM %s a, %s b WHERE a.brewerEmail = b.user_name ORDER BY brewerLastName ASC", $brewer_db_table, $users_db_table); $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); $row_brewer = mysqli_fetch_assoc($brewer); $totalRows_brewer = mysqli_num_rows($brewer); } - - // @single elseif ((($section == "admin") && ($go == "participants") && ($filter == "with_entries") && ($dbTable == "default"))) { - $query_brewer = sprintf("SELECT b.id, b.uid, b.brewerEmail, b.brewerLastName, b.brewerFirstName, b.brewerPhone1, b.brewerBreweryName, cb . * FROM (SELECT brewBrewerLastName, brewBrewerFirstName, brewBrewerID, GROUP_CONCAT( id ORDER BY id ) AS 'Entries' FROM %s GROUP BY brewBrewerLastName, brewBrewerFirstName, brewBrewerID) cb, %s b WHERE cb.brewBrewerID = b.uid", $prefix."brewing", $prefix."brewer"); - if (SINGLE) $query_brewer .= sprintf(" AND FIND_IN_SET('%s',brewerCompParticipant) > 0", $_SESSION['comp_id']); + $query_brewer = sprintf("SELECT a.id AS user_id, a.user_name, a.userLevel, a.userAdminObfuscate, b.id, b.uid, b.brewerEmail, b.brewerLastName, b.brewerFirstName, b.brewerPhone1, b.brewerBreweryName, cb.* FROM (SELECT brewBrewerLastName, brewBrewerFirstName, brewBrewerID, GROUP_CONCAT(id ORDER BY id) AS 'Entries', GROUP_CONCAT(brewJudgingNumber ORDER BY brewJudgingNumber) AS 'JudgingNums' FROM %s GROUP BY brewBrewerLastName, brewBrewerFirstName, brewBrewerID) cb, %s a, %s b WHERE cb.brewBrewerID = b.uid AND a.id = b.uid;", $prefix."brewing", $prefix."users", $prefix."brewer"); $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); $row_brewer = mysqli_fetch_assoc($brewer); $totalRows_brewer = mysqli_num_rows($brewer); @@ -74,9 +69,9 @@ else { - $query_brewer = "SELECT * FROM $brewer_db_table"; - if ($id == "default") $query_brewer .= " WHERE brewerJudge='Y'"; - if ($id != "default") $query_brewer .= sprintf(" WHERE id='%s'",$id); + $query_brewer = sprintf("SELECT a.*, b.id AS user_id, b.user_name, b.userLevel, b.userAdminObfuscate FROM %s a, %s b WHERE a.brewerEmail = b.user_name", $brewer_db_table, $users_db_table); + if ($id == "default") $query_brewer .= " AND brewerJudge='Y'"; + if ($id != "default") $query_brewer .= sprintf(" WHERE a.id='%s'",$id); $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); $row_brewer = mysqli_fetch_assoc($brewer); $totalRows_brewer = mysqli_num_rows($brewer); @@ -93,9 +88,9 @@ else { - $query_brewer = "SELECT * FROM $brewer_db_table"; - if ($id == "default") $query_brewer .= " WHERE brewerSteward='Y'"; - if ($id != "default") $query_brewer .= sprintf(" WHERE id='%s'",$id); + $query_brewer = sprintf("SELECT a.*, b.id AS user_id, b.user_name, b.userLevel, b.userAdminObfuscate FROM %s a, %s b WHERE a.brewerEmail = b.user_name", $brewer_db_table, $users_db_table); + if ($id == "default") $query_brewer .= " AND brewerSteward='Y'"; + if ($id != "default") $query_brewer .= sprintf(" WHERE a.id='%s'",$id); $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); $row_brewer = mysqli_fetch_assoc($brewer); $totalRows_brewer = mysqli_num_rows($brewer); @@ -105,7 +100,6 @@ } // Viewing all participants from archive query - // @single - needed? elseif (($section == "admin") && ($go == "participants") && ($filter == "default") && ($dbTable != "default")) { $query_brewer = "SELECT * FROM $dbTable ORDER BY brewerLastName"; $brewer = mysqli_query($connection,$query_brewer) or die (mysqli_error($connection)); @@ -116,7 +110,6 @@ // Updating assigned judges query elseif (($section == "admin") && ($go == "judging") && ($filter == "judges") && ($dbTable == "default") && ($action == "update")) { - // @single if (SINGLE) include (SSO.'assigned_judges.db.php'); @@ -146,6 +139,7 @@ $totalRows_brewer = mysqli_num_rows($brewer); } + } // Assign Judge query @@ -161,6 +155,7 @@ $totalRows_brewer = mysqli_num_rows($brewer); } + } // Assign Steward query @@ -176,6 +171,7 @@ $totalRows_brewer = mysqli_num_rows($brewer); } + } // Assign staff query diff --git a/includes/process.inc.php b/includes/process.inc.php index c641b88b..d7fc4e89 100644 --- a/includes/process.inc.php +++ b/includes/process.inc.php @@ -206,7 +206,7 @@ } // Data clean up - elseif (($action == "purge") || ($action == "cleanup")) include(INCLUDES.'data_cleanup.inc.php'); + elseif (($action == "purge") || ($action == "cleanup")) include (INCLUDES.'data_cleanup.inc.php'); // Regenerate judging numbers elseif ($action == "generate_judging_numbers") { diff --git a/includes/process/process_users.inc.php b/includes/process/process_users.inc.php index f75616b7..b82f6b3f 100644 --- a/includes/process/process_users.inc.php +++ b/includes/process/process_users.inc.php @@ -203,7 +203,7 @@ } - // User name not found. Update. + // User name not found. OK to update. if ($totalRows_userCheck < 1) { $update_table = $prefix."users"; @@ -218,9 +218,14 @@ $errors = TRUE; } + // Previously, changed the brewer record based upon a match of the user id and the brewer uid + // Match using the old email address, update the new email address in the brewer table as well $update_table = $prefix."brewer"; - $data = array('brewerEmail' => $username); - $db_conn->where ('uid', $id); + $data = array( + 'brewerEmail' => $username, + 'uid' => $id + ); + $db_conn->where ('brewerEmail', $row_brewerCheck['brewerEmail']); $result = $db_conn->update ($update_table, $data); if (!$result) { $error_output[] = $db_conn->getLastError(); diff --git a/lib/common.lib.php b/lib/common.lib.php index 2adf3733..69323e28 100644 --- a/lib/common.lib.php +++ b/lib/common.lib.php @@ -3119,7 +3119,7 @@ function table_assignments($uid,$method,$time_zone,$date_format,$time_format,$me if ($method2 == 2) $output = array(); else $output = ""; - $query_table_assignments = sprintf("SELECT assignTable,assignRoles,assignFlight,assignRound FROM %s WHERE bid='%s' AND assignment='%s'",$prefix."judging_assignments",$uid,$method); + $query_table_assignments = sprintf("SELECT assignTable,assignRoles,assignFlight,assignRound FROM %s WHERE bid='%s' AND assignment='%s' ORDER BY assignTable ASC",$prefix."judging_assignments",$uid,$method); $table_assignments = mysqli_query($connection,$query_table_assignments) or die (mysqli_error($connection)); $row_table_assignments = mysqli_fetch_assoc($table_assignments); $totalRows_table_assignments = mysqli_num_rows($table_assignments); @@ -3166,7 +3166,7 @@ function table_assignments($uid,$method,$time_zone,$date_format,$time_format,$me elseif ($method2 == 1) { if ((isset($table_info[0])) && (isset($table_info[1])) && (isset($table_info[3]))) { - if ($method == "J") $output .= "".$table_info[0]." - ".$table_info[1].", "; + if ($method == "J") $output .= $table_info[0]." - ".$table_info[1].", "; if ($method == "S") $output .= "".$table_info[0]." - ".$table_info[1].", "; } } diff --git a/sections/user.sec.php b/sections/user.sec.php index df774b06..5541eccf 100644 --- a/sections/user.sec.php +++ b/sections/user.sec.php @@ -54,7 +54,7 @@

-
" method="POST" name="form1"> +" method="POST" name="form1"> ">