Skip to content

Commit

Permalink
Finalize Version 2.7.2 - Partially Address #1580
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffhumphrey committed Oct 18, 2024
1 parent f6f53f7 commit cffdfea
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 72 deletions.
2 changes: 1 addition & 1 deletion admin/judging_locations.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@

}

if ($none_selected == 0) {
if ((isset($none_selected)) && ($none_selected == 0)) {
if ($filter != "staff") $output .= "<span class=\"fa fa-sm fa-ban text-danger\"></span> <a href=\"".$base_url."index.php?section=brewer&amp;go=admin&amp;action=edit&amp;filter=".$row_brewer['uid']."&amp;id=".$row_brewer['uid']."\" data-toggle=\"tooltip\" title=\"Enter ".$row_brewer['brewerFirstName']." ".$row_brewer['brewerLastName']."&rsquo;s location preferences\">None specified</a>.";
}

Expand Down
107 changes: 59 additions & 48 deletions admin/participants.admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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."&rsquo;s User Level");
else $output_datatables_other_link = "<span class=\"fa fa-lg fa-lock text-muted\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"You cannot change your own user level, ".$_SESSION['brewerFirstName'].".\"></span>";

$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."&rsquo;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."&rsquo;s email address");

}

Expand Down Expand Up @@ -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."&rsquo;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."&rsquo;s password");
}

else $output_datatables_change_pwd = "";
Expand All @@ -299,7 +296,7 @@

if ($filter == "with_entries") {
unset($entries);

unset($judging_nums);
$output_datatables_body .= "<tr>";
if ($pro_edition == 1) $output_datatables_body .= "<td>".$row_brewer['brewerBreweryName']."</td>";
else {
Expand All @@ -318,74 +315,88 @@

$brewer_entries = implode(",",$entries);

$output_datatables_body .= "<td><a href=\"".$base_url."index.php?section=admin&amp;go=entries&amp;bid=".$row_brewer['uid']."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"List ".$brewer_tooltip_display_name."&rsquo;s entries.\"><i class=\"fa fa-list\"></i></a> ".str_replace(",",", ",$brewer_entries)."</td>";
$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 .= "<td><a href=\"".$base_url."index.php?section=admin&amp;go=entries&amp;bid=".$row_brewer['uid']."\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"List ".$brewer_tooltip_display_name."&rsquo;s entries.\">Entry Numbers</a>: ".str_replace(",",", ",$brewer_entries)."<br>Judging Numbers: ".str_replace(",",", ",$brewer_entries_judging_nums)."</td>";
if ($action != "print") $output_datatables_body .= "<td>".$output_datatables_actions."</td>";
$output_datatables_body .= "</tr>";

}

else {

$table_assign_judge = table_assignments($user_info[0],"J",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1);
$table_assign_judge = str_replace(",&nbsp;","<br>",$table_assign_judge);

$table_assign_steward = table_assignments($user_info[0],"S",$_SESSION['prefsTimeZone'],$_SESSION['prefsDateFormat'],$_SESSION['prefsTimeFormat'],1);
$table_assign_steward = str_replace(",&nbsp;","<br>",$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(",&nbsp;","<br>",$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(",&nbsp;","<br>",$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 = "<p>".$row_brewer['brewerFirstName']." is assigned as a <strong>judge</strong> to table(s): ".$table_assign_judge."<p>";
else $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." has been added to the <strong>judge</strong> pool, but has not been assigned to a table yet.<p>";
}
if (strpos($brewer_assignment,"Steward") !== false) {
if (!empty($table_assign_steward)) $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." is assigned as a <strong>steward</strong> to table(s): ".$table_assign_steward."<p>";
else $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." has been added to the <strong>steward</strong> pool, but has not been assigned to a table yet.<p>";
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 = "<p>".$row_brewer['brewerFirstName']." is assigned as a <strong>judge</strong> to table(s):<br>".$table_assign_judge."</p>";
else $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." has been added to the <strong>judge</strong> pool, but has not been assigned to a table yet.</p>";
}
if (strpos($brewer_assignment,"Steward") !== false) {
if (!empty($table_assign_steward)) $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." is assigned as a <strong>steward</strong> to table(s):<br>".$table_assign_steward."</p>";
else $assignment_modal_body = "<p>".$row_brewer['brewerFirstName']." has been added to the <strong>steward</strong> pool, but has not been assigned to a table yet.</p>";
}
if (!empty($judge_entries)) $assignment_modal_body .= "<p>Has entries in: ".$judge_entries."</p>";
$output_assignment_modals .= "<div class=\"modal fade\" id=\"assignment-modal-".$row_brewer['uid']."\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"assignment-modal-label-".$row_brewer['uid']."\">\n";
$output_assignment_modals .= "\t<div class=\"modal-dialog modal-lg\" role=\"document\">\n";
$output_assignment_modals .= "\t\t<div class=\"modal-content\">\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-header bcoem-admin-modal\">\n";
$output_assignment_modals .= "\t\t\t\t<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n";
$output_assignment_modals .= "\t\t\t\t<h4 class=\"modal-title\" id=\"assignment-modal-label-".$row_brewer['uid']."\">Assignment(s) for ".$brewer_tooltip_display_name."</h4>\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-header -->\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-body\">\n";
$output_assignment_modals .= "\t\t\t\t".$assignment_modal_body."\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-body -->\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-footer\">\n";
$output_assignment_modals .= "\t\t\t\t<button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button>\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-footer -->\n";
$output_assignment_modals .= "\t\t</div><!-- ./modal-content -->\n";
$output_assignment_modals .= "\t</div><!-- ./modal-dialog -->\n";
$output_assignment_modals .= "</div><!-- ./modal -->\n";
}
if (!empty($judge_entries)) $assignment_modal_body .= "<p>Has entries in: ".$judge_entries."</p>";
$output_assignment_modals .= "<div class=\"modal fade\" id=\"assignment-modal-".$row_brewer['uid']."\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"assignment-modal-label-".$row_brewer['uid']."\">\n";
$output_assignment_modals .= "\t<div class=\"modal-dialog modal-lg\" role=\"document\">\n";
$output_assignment_modals .= "\t\t<div class=\"modal-content\">\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-header bcoem-admin-modal\">\n";
$output_assignment_modals .= "\t\t\t\t<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span aria-hidden=\"true\">&times;</span></button>\n";
$output_assignment_modals .= "\t\t\t\t<h4 class=\"modal-title\" id=\"assignment-modal-label-".$row_brewer['uid']."\">Assignment(s) for ".$brewer_tooltip_display_name."</h4>\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-header -->\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-body\">\n";
$output_assignment_modals .= "\t\t\t\t".$assignment_modal_body."\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-body -->\n";
$output_assignment_modals .= "\t\t\t<div class=\"modal-footer\">\n";
$output_assignment_modals .= "\t\t\t\t<button type=\"button\" class=\"btn btn-danger\" data-dismiss=\"modal\">Close</button>\n";
$output_assignment_modals .= "\t\t\t</div><!-- ./modal-footer -->\n";
$output_assignment_modals .= "\t\t</div><!-- ./modal-content -->\n";
$output_assignment_modals .= "\t</div><!-- ./modal-dialog -->\n";
$output_assignment_modals .= "</div><!-- ./modal -->\n";

}

}

$output_datatables_body .= "<tr>";

$output_datatables_body .= "<td>";
$output_datatables_body .= "<a name='".$row_brewer['uid']."'></a>";
$output_datatables_body .= $row_brewer['brewerLastName'].", ".$row_brewer['brewerFirstName'];
if (($dbTable == "default") && ($user_info[1] == 0)) $output_datatables_body .= " <i class=\"fa fa-sm fa-lock text-danger\"></i>";
elseif (($dbTable == "default") && ($user_info[1] == 1)) $output_datatables_body .= " <i class=\"fa fa-sm fa-lock text-warning\"></i>";
if (($dbTable == "default") && ($row_brewer['userLevel'] == 0)) $output_datatables_body .= " <i class=\"fa fa-sm fa-lock text-danger\"></i>";
elseif (($dbTable == "default") && ($row_brewer['userLevel'] == 1)) $output_datatables_body .= " <i class=\"fa fa-sm fa-lock text-warning\"></i>";
if ($action != "print") $output_datatables_body .= "<br><small>".$row_brewer['brewerCity'].", ".$row_brewer['brewerState']."</small>";
$output_datatables_body .= "</td>";

$output_datatables_body .= "<td>";
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 .= " <i class=\"fa fa-sm fa-eye\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name." can view Judging Numbers - edit their user level to change.\"></i>";
if (($dbTable == "default") && ($row_brewer['userLevel'] == 0)) $output_datatables_body .= " <i class=\"fa fa-sm fa-eye\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name." can view Judging Numbers - edit their user level to change.\"></i>";
else $output_datatables_body .= " <i class=\"fa fa-sm fa-eye-slash\" data-toggle=\"tooltip\" data-placement=\"top\" title=\"".$brewer_tooltip_display_name." CANNOT view Judging Numbers - edit their user level to change.\"></i>";
$output_datatables_body .= "</td>";

Expand Down Expand Up @@ -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 .= "<button type=\"button\" class=\"btn btn-link\" style=\"margin:0; padding:0;\" data-toggle=\"modal\" data-target=\"#assignment-modal-".$row_brewer['uid']."\">".ucwords($brewer_assignment)."</button>";
}
else {
Expand Down
28 changes: 12 additions & 16 deletions includes/db/brewer.db.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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));
Expand All @@ -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');

Expand Down Expand Up @@ -146,6 +139,7 @@
$totalRows_brewer = mysqli_num_rows($brewer);

}

}

// Assign Judge query
Expand All @@ -161,6 +155,7 @@
$totalRows_brewer = mysqli_num_rows($brewer);

}

}

// Assign Steward query
Expand All @@ -176,6 +171,7 @@
$totalRows_brewer = mysqli_num_rows($brewer);

}

}

// Assign staff query
Expand Down
2 changes: 1 addition & 1 deletion includes/process.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
11 changes: 8 additions & 3 deletions includes/process/process_users.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@

}

// User name not found. Update.
// User name not found. OK to update.
if ($totalRows_userCheck < 1) {

$update_table = $prefix."users";
Expand All @@ -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();
Expand Down
Loading

0 comments on commit cffdfea

Please sign in to comment.