Resolved errors

This commit is contained in:
arman 2025-02-07 20:48:27 +00:00
parent f12445c5d0
commit 32f35b02fe
12 changed files with 275 additions and 194 deletions

View File

@ -23,10 +23,10 @@
*/
?>
<?
require('../common.inc.php');
require_once('../user.inc.php');
require ('../common.inc.php');
require_once ('../user.inc.php');
user_auth_required('committee', 'admin');
require_once('fundraising_common.inc.php');
require_once ('fundraising_common.inc.php');
global $pdo;
@ -43,9 +43,7 @@ switch (get_value_from_array($_GET, 'action')) {
case 'organizationinfo_save':
$id = intval($_POST['sponsor_id']);
if ($id == -1) {
echo "INSERT INTO sponsors (year) VALUES ('" . $config['FAIRYEAR'] . "')";
$q = $pdo->prepare("INSERT INTO sponsors (year) VALUES ('" . $config['FAIRYEAR'] . "')");
$q->execute();
$id = $pdo->lastInsertId();
@ -55,7 +53,6 @@ switch (get_value_from_array($_GET, 'action')) {
} else
$createnew = false;
if ($id) {
if ($_POST['fundingselectiondate'] == '') {
$_POST['fundingselectiondate'] = '0000-00-00';
}
@ -89,7 +86,7 @@ switch (get_value_from_array($_GET, 'action')) {
. "WHERE id='$id'";
$q = $pdo->prepare($exec);
$q->execute();
echo $q->errorInfo();
show_pdo_errors_if_any($pdo);
// FIXME accept the logo
// "logo='".mysql_escape_string(stripslashes($_POST['logo']))."', ".
@ -337,7 +334,7 @@ switch (get_value_from_array($_GET, 'action')) {
case 'contactsinfo_load':
// make sure a donor id has been selected
if ($_GET['id']) {
if ($_GET['id']) {
draw_contactsinfo_form();
}
exit;
@ -357,7 +354,7 @@ switch (get_value_from_array($_GET, 'action')) {
break;
case 'activityinfo_load':
// make sure a donor id has been selected
if ($_GET['id']) {
if ($_GET['id']) {
draw_activityinfo_form();
}
exit;
@ -389,13 +386,13 @@ switch (get_value_from_array($_GET, 'action')) {
echo "<li><a href=\"#\" onclick=\"useexistingcontact($r->uid)\">$r->firstname $r->lastname $r->email $r->phonehome</a></li>\n";
echo '</ul>';
?>
?>
<script type="text/javascript">
$("#contactnewsave").attr("disabled", "disabled");
</script>
<?
} else {
?>
?>
<script type="text/javascript">
$("#contactnewsave").attr("disabled", "");
</script>
@ -642,6 +639,7 @@ function draw_contactsinfo_form($contact = null)
echo "<div id=\"contactaccordion\" style=\"width: 740px;\">\n";
// loop through each contact and draw a form with their data in it.
$query = $pdo->prepare("SELECT *,MAX(year) FROM users LEFT JOIN users_sponsor ON users_sponsor.users_id=users.id
WHERE
sponsors_id='" . $sponsor_id . "'
@ -822,7 +820,7 @@ function draw_activityinfo_form()
global $config, $pdo;
$sponsorid = $_GET['id'];
// we'll start by drawing the table header
?>
?>
<form id="activityinfo">
<table class="tableview" style="width:99%">
<thead>
@ -868,10 +866,10 @@ function draw_activityinfo_form()
<?php
$query = "SELECT CONCAT_WS('&nbsp;', users.firstname, users.lastname) AS name, fdl.dt, fdl.log, fdl.type,
fundraising_campaigns.name AS campaignname
FROM fundraising_donor_logs AS fdl
LEFT JOIN users ON fdl.users_id=users.id
LEFT JOIN fundraising_campaigns ON fdl.fundraising_campaigns_id=fundraising_campaigns.id
WHERE sponsors_id=" . $sponsorid . ' ORDER BY dt DESC';
\t FROM fundraising_donor_logs AS fdl
\t LEFT JOIN users ON fdl.users_id=users.id
\t LEFT JOIN fundraising_campaigns ON fdl.fundraising_campaigns_id=fundraising_campaigns.id
\t WHERE sponsors_id=" . $sponsorid . ' ORDER BY dt DESC';
// echo "<tr><td colspan=\"3\">" . $query . "</td></tr>";
$q = $pdo->prepare($query);
$q->execute();
@ -966,12 +964,19 @@ function getDonationString($id)
$("#editor_tabs").tabs({
create: function(event, ui) {
update_contactsinfo();
update_organizationinfo();
update_sponsorshipinfo();
update_activityinfo();
},
activate: function(event, ui) {
update_organizationinfo();
update_sponsorshipinfo();
update_contactsinfo();
update_activityinfo();
},
selected: 0
selected: -1
});
$("#organizationinfo_fundingselectiondate").datepicker({
@ -1018,6 +1023,7 @@ function getDonationString($id)
} else {
$('#editor_tabs').tabs('option', 'selected', 0);
$('#editor_tabs').tabs('option', 'collapsible', true);
$('#editor_tabs').tabs('option', 'disabled', []);
}
@ -1332,21 +1338,21 @@ echo '<hr />';
<?
/*
* <tr><td><?=i18n("Waiver Accepted")?></td><td>
* <input type="radio" id="organizationinfo_waiveraccepted_no" name="waiveraccepted" value="no"><label for="organizationinfo_waiveraccepted_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_waiveraccepted_yes" name="waiveraccepted" value="yes"><label for="organizationinfo_waiveraccepted_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td>
*
* <td><?=i18n("Tax Receipt Requested")?></td><td>
* <input type="radio" id="organizationinfo_taxreceiptrequired_no" name="taxreceiptrequired" value="no"><label for="organizationinfo_taxreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_taxreceiptrequired_yes" name="taxreceiptrequired" value="yes"><label for="organizationinfo_taxreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td>
*
* <td><?=i18n("Marketing Receipt Requested")?></td><td colspan="3">
* <input type="radio" id="organizationinfo_marketingreceiptrequired_no" name="marketingreceiptrequired" value="no"><label for="organizationinfo_marketingreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_marketingreceiptrequired_yes" name="marketingreceiptrequired" value="yes"><label for="organizationinfo_marketingreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td></tr>
*/
* <tr><td><?=i18n("Waiver Accepted")?></td><td>
* <input type="radio" id="organizationinfo_waiveraccepted_no" name="waiveraccepted" value="no"><label for="organizationinfo_waiveraccepted_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_waiveraccepted_yes" name="waiveraccepted" value="yes"><label for="organizationinfo_waiveraccepted_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td>
*
* <td><?=i18n("Tax Receipt Requested")?></td><td>
* <input type="radio" id="organizationinfo_taxreceiptrequired_no" name="taxreceiptrequired" value="no"><label for="organizationinfo_taxreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_taxreceiptrequired_yes" name="taxreceiptrequired" value="yes"><label for="organizationinfo_taxreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td>
*
* <td><?=i18n("Marketing Receipt Requested")?></td><td colspan="3">
* <input type="radio" id="organizationinfo_marketingreceiptrequired_no" name="marketingreceiptrequired" value="no"><label for="organizationinfo_marketingreceiptrequired_no"><?=i18n("No")?></label> &nbsp;&nbsp;
* <input type="radio" id="organizationinfo_marketingreceiptrequired_yes" name="marketingreceiptrequired" value="yes"><label for="organizationinfo_marketingreceiptrequired_yes"><?=i18n("Yes")?></label> &nbsp;&nbsp;
* </td></tr>
*/
?>
<tr>
<td><?= i18n('Notes') ?></td>
@ -1382,7 +1388,7 @@ echo '<hr />';
<?
if (get_value_from_array($_GET, 'action') == 'add') {
?>
?>
<script type="text/javascript">
$(document).ready(function() {
open_editor(-1);

View File

@ -592,6 +592,12 @@ function modifycampaignsfinish(){
function managecampaignfinish() {
$("#campaign_tabs").tabs({
create: function(event, ui) {
update_tab_overview();
update_tab_donations();
update_tab_prospects();
update_tab_communications();
},
activate: function( event, ui ) {
update_tab_overview();
update_tab_donations();

View File

@ -34,14 +34,14 @@ if (!$q->rowCount()) {
$q = $pdo->prepare("SELECT * FROM fundraising_donor_levels WHERE fiscalyear='-1'");
$q->execute();
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
$pdo->prepare("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES (
$stmt = $pdo->prepare("INSERT INTO fundraising_donor_levels (`level`,`min`,`max`,`description`,`fiscalyear`) VALUES (
'" . $r->level . "',
'" . $r->min . "',
'" . $r->max . "',
'" . $r->description . "',
'" . $config['FISCALYEAR'] . ")')");
$pdo->execute();
$stmt->execute();
}
}
@ -346,12 +346,17 @@ send_header('Fundraising Setup',
$(document).ready(function() {
$("#editor_tabs").tabs({
create: function(event, ui) {
update_levels();
update_goals();
update_setup();
},
activate: function( event, ui ) {
update_levels();
update_goals();
update_setup();
},
selected: 0
selected: 1
});
// $("#editor_tabs").tabs({

View File

@ -193,8 +193,8 @@ if ($action == 'savemultiple') {
$q->execute();
show_pdo_errors_if_any($pdo);
$r = $q->fetch(PDO::FETCH_OBJ);
list($ed, $et) = split(' ', $r->endtime);
list($nd, $nt) = split(' ', $r->startnext);
list($ed, $et) = explode(' ', $r->endtime);
list($nd, $nt) = explode(' ', $r->startnext);
$starttime = sprintf('%02d:%02d:00', $hr, $min);
@ -205,8 +205,8 @@ if ($action == 'savemultiple') {
$stmt->execute();
show_pdo_errors_if_any($pdo);
$date = $nd;
list($s_h, $s_m, $s_s) = split(':', $nt);
list($e_h, $e_m, $e_s) = split(':', $et);
list($s_h, $s_m, $s_s) = explode(':', $nt);
list($e_h, $e_m, $e_s) = explode(':', $et);
message_push(happy(i18n('Adding timeslot: %1', array("$date $hr:$min - $e_h:$e_m"))));
$hr = $s_h;
$min = $s_m;

View File

@ -313,6 +313,12 @@ $(document).ready(function() {
$("#editor_tabs").tabs({
create: function(event, ui) {
update_students();
update_project();
update_reg();
},
activate: function( event, ui ) {
update_students();
update_project();

View File

@ -193,7 +193,7 @@ if (get_value_from_array($_GET, 'action') == 'delete' && get_value_from_array($_
}
if (get_value_from_array($_GET, 'action') == 'clearaccesscodes') {
$stmt = $pdo->prepare("UPDATE schools SET accesscode=NULL WHERE year='{$config['FAIRYEAR']}'");
$stmt = $pdo->prepare("UPDATE schools SET accesscode='' WHERE year='{$config['FAIRYEAR']}'");
$stmt->execute();
$notice = 'clearaccess';
}
@ -237,8 +237,9 @@ if (get_value_from_array($_GET, 'action') == 'edit' || get_value_from_array($_GE
echo '<tr><td>' . i18n('School Language') . '</td><td>';
echo '<select name="schoollang">';
echo '<option value="">' . i18n('Choose') . "</option>\n";
foreach ($config['languages'] AS $k => $l) {
echo "<option $sel value=\"$k\">" . i18n($limportant_dates) . "</option>\n";
echo "<option $sel value=\"$k\">" . i18n($l) . "</option>\n";
}
echo '</select>';

View File

@ -50,6 +50,11 @@ if (get_value_from_array($_POST, 'action') == 'save' && get_value_from_array($_P
}
if (get_value_from_array($_POST, 'action') == 'new') {
if ($_POST['ord'] == ''){
$_POST['ord'] = 0;
}
if ($_POST['question']) {
$stmt = $pdo->prepare("INSERT INTO safetyquestions (question,type,required,ord,year) VALUES (
'" . stripslashes($_POST['question']) . "',
@ -89,15 +94,19 @@ if ((get_value_from_array($_GET, 'action') == 'edit' && get_value_from_array($_G
$showform = false;
echo error(i18n('Invalid safety question'));
}
}
if ($showform) {
$r = array();
echo '<table class="summarytable">';
echo '<tr><td>' . i18n('Question') . '</td><td>';
echo '<input size="60" type="text" name="question" value="' . htmlspecialchars(get_value_from_array($r, 'question', '')) . "\">\n";
echo '<input size="60" type="text" name="question" value="' . htmlspecialchars($r->question) . "\">\n";
echo '</td></tr>';
echo '<tr><td>' . i18n('Type') . '</td><td>';
echo '<select name="type">';
if ($r->type == 'check')
$sel = 'selected="selected"';
else
@ -125,7 +134,7 @@ if ((get_value_from_array($_GET, 'action') == 'edit' && get_value_from_array($_G
echo '</select>';
echo '</td>';
echo '<tr><td>' . i18n('Display Order') . '</td><td>';
echo '<input size="5" type="text" name="ord" value="' . htmlspecialchars(get_value_from_array($r, 'ord', '')) . "\">\n";
echo '<input size="5" type="text" name="ord" value="' . htmlspecialchars($r->ord) . "\">\n";
echo '</td></tr>';
echo '<tr><td colspan="2" align="center">';
echo '<input type="submit" value="' . i18n($buttontext) . "\" />\n";
@ -137,6 +146,7 @@ if ((get_value_from_array($_GET, 'action') == 'edit' && get_value_from_array($_G
} else {
}
}
echo '<br />';
echo '<a href="safetyquestions.php?action=new">' . i18n('Add new safety question') . '</a>';

View File

@ -1,40 +1,44 @@
<?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website: http://www.sfiab.ca
Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
Copyright (C) 2005 James Grant <james@lightbox.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/*
* This file is part of the 'Science Fair In A Box' project
* SFIAB Website: http://www.sfiab.ca
*
* Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
* Copyright (C) 2005 James Grant <james@lightbox.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
?>
<?
function registrationFormsReceived($reg_id = "")
function registrationFormsReceived($reg_id = '')
{
global $pdo;
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
$q = $pdo->prepare("SELECT status FROM registrations WHERE id='$rid'");
$q->execute();
$r = $q->fetch(PDO::FETCH_OBJ);
if ($r->status == "complete" || $r->status == "paymentpending")
if ($r->status == 'complete' || $r->status == 'paymentpending')
return true;
else
return false;
}
function registrationDeadlinePassed()
{
global $config, $pdo;
@ -47,49 +51,53 @@ function registrationDeadlinePassed()
return true;
}
function studentStatus($reg_id = "")
function studentStatus($reg_id = '')
{
global $config, $pdo;
if ($config['participant_student_personal'] == "yes")
$required_fields = array("firstname", "lastname", "address", "city", "postalcode", "phone", "email", "grade", "dateofbirth", "schools_id", "sex");
if ($config['participant_student_personal'] == 'yes')
$required_fields = array('firstname', 'lastname', 'address', 'city', 'postalcode', 'phone', 'email', 'grade', 'dateofbirth', 'schools_id', 'sex');
else
$required_fields = array("firstname", "lastname", "email", "grade", "schools_id");
$required_fields = array('firstname', 'lastname', 'email', 'grade', 'schools_id');
if ($config['participant_student_tshirt'] == "yes")
$required_fields[] = "tshirt";
if ($config['participant_student_tshirt'] == 'yes')
$required_fields[] = 'tshirt';
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
$q = $pdo->prepare("SELECT * FROM students WHERE registrations_id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
//if we dont have the minimum, return incomplete
// if we dont have the minimum, return incomplete
if ($q->rowCount() < $config['minstudentsperproject'])
return "incomplete";
return 'incomplete';
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
foreach ($required_fields as $req) {
if ($req == "dateofbirth") {
if ($r->$req == "0000-00-00" || !$r->$req)
return "incomplete";
if ($req == 'dateofbirth') {
if ($r->$req == '0000-00-00' || !$r->$req)
return 'incomplete';
} else {
if (!$r->$req)
return "incomplete";
return 'incomplete';
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
// if it made it through without returning incomplete, then we must be complete
return 'complete';
}
function emergencycontactStatus($reg_id = "")
function emergencycontactStatus($reg_id = '')
{
global $config, $pdo;
$required_fields = array("firstname", "lastname", "relation", "phone1");
$required_fields = array('firstname', 'lastname', 'relation', 'phone1');
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
$sq = $pdo->prepare("SELECT id FROM students WHERE registrations_id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$sq->execute();
@ -102,19 +110,19 @@ function emergencycontactStatus($reg_id = "")
foreach ($required_fields as $req) {
if (!$r->$req) {
return "incomplete";
return 'incomplete';
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
// if it made it through without returning incomplete, then we must be complete
return 'complete';
}
function projectStatus($reg_id = "")
function projectStatus($reg_id = '')
{
global $config, $pdo;
$required_fields = array("title", "projectcategories_id", "projectdivisions_id", "language", "req_table", "req_electricity", "summarycountok");
$required_fields = array('title', 'projectcategories_id', 'projectdivisions_id', 'language', 'req_table', 'req_electricity', 'summarycountok');
if ($config['participant_short_title_enable'] == 'yes')
$required_fields[] = 'shorttitle';
@ -127,92 +135,101 @@ function projectStatus($reg_id = "")
if ($config['participant_project_summary_wordmin'] > 0)
$required_fields[] = 'summary';
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
$q = $pdo->prepare("SELECT * FROM projects WHERE registrations_id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
//if we dont have a project entry yet, return empty
// if we dont have a project entry yet, return empty
if (!$q->rowCount())
return "empty";
return 'empty';
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
foreach ($required_fields as $req) {
if (!$r->$req) {
return "incomplete";
return 'incomplete';
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
// if it made it through without returning incomplete, then we must be complete
return 'complete';
}
function mentorStatus($reg_id = "")
function mentorStatus($reg_id = '')
{
global $config, $pdo;
$required_fields = array("firstname", "lastname", "phone", "email", "organization", "description");
$required_fields = array('firstname', 'lastname', 'phone', 'email', 'organization', 'description');
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
//first check the registrations table to see if 'nummentors' is set, or if its null
// first check the registrations table to see if 'nummentors' is set, or if its null
$q = $pdo->prepare("SELECT nummentors FROM registrations WHERE id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
$r = $q->fetch(PDO::FETCH_OBJ);
if ($r->nummentors == null)
return "incomplete";
if ($r->nummentors === -1) {
return 'incomplete';
}
$q = $pdo->prepare("SELECT * FROM mentors WHERE registrations_id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
//if we dont have the minimum, return incomplete
// if we dont have the minimum, return incomplete
if ($q->rowCount() < get_value_from_array($config, 'minmentorserproject'))
return "incomplete";
return 'incomplete';
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
foreach ($required_fields as $req) {
if (!$r->$req) {
return "incomplete";
return 'incomplete';
}
}
}
//if it made it through without returning incomplete, then we must be complete
return "complete";
// if it made it through without returning incomplete, then we must be complete
return 'complete';
}
function safetyStatus($reg_id = "")
function safetyStatus($reg_id = '')
{
global $config, $pdo;
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
//grab all of their answers
// grab all of their answers
$q = $pdo->prepare("SELECT * FROM safety WHERE registrations_id='$rid'");
$q->execute();
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
$safetyanswers[$r->safetyquestions_id] = $r->answer;
}
//now grab all the questions
// now grab all the questions
$q = $pdo->prepare("SELECT * FROM safetyquestions WHERE year='" . $config['FAIRYEAR'] . "' ORDER BY ord");
$q->execute();
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
if ($r->required == "yes" && !$safetyanswers[$r->id]) {
return "incomplete";
if ($r->required == 'yes' && !$safetyanswers[$r->id]) {
return 'incomplete';
}
}
return "complete";
return 'complete';
}
function spawardStatus($reg_id = "")
function spawardStatus($reg_id = '')
{
global $config, $pdo;
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
$q = $pdo->prepare("SELECT * FROM projects WHERE registrations_id='$rid'");
$q->execute();
@ -231,26 +248,28 @@ function spawardStatus($reg_id = "")
$awardsq->execute();
if ($awardsq->rowCount())
return "complete";
return 'complete';
else
return "incomplete";
return 'incomplete';
}
function tourStatus($reg_id = "")
function tourStatus($reg_id = '')
{
global $config, $pdo;
if ($reg_id) $rid = $reg_id;
else $rid = $_SESSION['registration_id'];
if ($reg_id)
$rid = $reg_id;
else
$rid = $_SESSION['registration_id'];
/* Get the students for this project */
$q = $pdo->prepare("SELECT * FROM students WHERE registrations_id='$rid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
$num_found = $q->rowCount();
$ret = "complete";
$ret = 'complete';
while ($s = $q->fetch(PDO::FETCH_OBJ)) {
//grab all of their tour prefs
// grab all of their tour prefs
$sid = $s->id;
$qq = $pdo->prepare("SELECT * FROM tours_choice WHERE students_id='$sid' and year='{$config['FAIRYEAR']}' ORDER BY rank");
$qq->execute();
@ -259,23 +278,28 @@ function tourStatus($reg_id = "")
/* See if there's a rank 0 tour (rank 0 == their tour assignment) */
$i = $qq->fetch(PDO::FETCH_OBJ);
if ($i->rank == 0) {
/* Yes, there is, no matter what, this student's tour
* selection is complete. */
/*
* Yes, there is, no matter what, this student's tour
* selection is complete.
*/
continue;
}
}
/* Else, they haven't been assigned a tour, see if they've made
* the appropraite selection(s) */
/*
* Else, they haven't been assigned a tour, see if they've made
* the appropraite selection(s)
*/
if (($n_tours >= $config['tours_choices_min']) && ($n_tours <= $config['tours_choices_max'])) {
continue;
}
$ret = "incomplete";
$ret = 'incomplete';
break;
}
return $ret;
}
function namecheckStatus($reg_id = "")
function namecheckStatus($reg_id = '')
{
global $config, $pdo;
@ -300,14 +324,13 @@ function namecheckStatus($reg_id = "")
return 'complete';
}
function generateProjectNumber($registration_id)
{
global $config, $pdo;
$reg_id = $registration_id;
$q = $pdo->prepare("SELECT projects.projectcategories_id,
$q = $pdo->prepare("SELECT \tprojects.projectcategories_id,
projects.projectdivisions_id,
projectcategories.category_shortform,
projectdivisions.division_shortform
@ -317,10 +340,10 @@ function generateProjectNumber($registration_id)
projectdivisions
WHERE
registrations_id='$reg_id'
AND projects.projectdivisions_id=projectdivisions.id
AND projects.projectcategories_id=projectcategories.id
AND projectcategories.year='{$config['FAIRYEAR']}'
AND projectdivisions.year='{$config['FAIRYEAR']}'
AND\tprojects.projectdivisions_id=projectdivisions.id
AND\tprojects.projectcategories_id=projectcategories.id
AND\tprojectcategories.year='{$config['FAIRYEAR']}'
AND\tprojectdivisions.year='{$config['FAIRYEAR']}'
");
$q->execute();
show_pdo_errors_if_any($pdo);
@ -330,18 +353,23 @@ function generateProjectNumber($registration_id)
$p['number']['str'] = $config['project_num_format'];
$p['sort']['str'] = trim($config['project_sort_format']);
if ($p['sort']['str'] == '') $p['sort']['str'] = $p['number']['str'];
if ($p['sort']['str'] == '')
$p['sort']['str'] = $p['number']['str'];
/* Replace each letter with {letter}, so that we can do additional
/*
* Replace each letter with {letter}, so that we can do additional
* replacements below, without risking subsituting in a letter that may
* get replaced. */
* get replaced.
*/
foreach (array('number', 'sort') as $x) {
$p[$x]['str'] = preg_replace('[CcDd]', '{\\0}', $p[$x]['str']);
$p[$x]['str'] = preg_replace('(N|X)([0-9])?', '{\\0}', $p[$x]['str']);
$p[$x]['str'] = preg_replace('[CcDd]', '{\0}', $p[$x]['str']);
$p[$x]['str'] = preg_replace('(N|X)([0-9])?', '{\0}', $p[$x]['str']);
}
/* Do some replacements that we don' thave to do anything fancy with,
* and setup some variables for future queries */
/*
* Do some replacements that we don' thave to do anything fancy with,
* and setup some variables for future queries
*/
foreach (array('number', 'sort') as $x) {
$p[$x]['str'] = str_replace('{D}', $r->projectdivisions_id, $p[$x]['str']);
$p[$x]['str'] = str_replace('{C}', $r->projectcategories_id, $p[$x]['str']);
@ -351,9 +379,11 @@ function generateProjectNumber($registration_id)
$p[$x]['x_used'] = array();
}
/* Build a total list of projects for finding a global number, and
* while constructing the list, build a list for the division/cat
* sequence number */
/*
* Build a total list of projects for finding a global number, and
* while constructing the list, build a list for the division/cat
* sequence number
*/
$q = $pdo->prepare("SELECT projectnumber_seq,projectsort_seq,
projectdivisions_id,projectcategories_id
FROM projects
@ -363,9 +393,8 @@ function generateProjectNumber($registration_id)
$q->execute();
show_pdo_errors_if_any($pdo);
while ($i = $q->fetch(PDO::FETCH_OBJ)) {
if (($r->projectdivisions_id == $i->projectdivisions_id)
&& ($r->projectcategories_id == $i->projectcategories_id)
) {
if (($r->projectdivisions_id == $i->projectdivisions_id) &&
($r->projectcategories_id == $i->projectcategories_id)) {
$p['number']['n_used'][] = $i->projectnumber_seq;
$p['sort']['n_used'][] = $i->projectsort_seq;
}
@ -374,10 +403,12 @@ function generateProjectNumber($registration_id)
$p['sort']['x_used'][] = $i->projectsort_seq;
}
/* We only support one N or X to keep things simple, find which
* one we need and how much to pad it */
/*
* We only support one N or X to keep things simple, find which
* one we need and how much to pad it
*/
foreach (array('number', 'sort') as $x) {
if (preg_match("(N|X)([0-9])?", $p[$x]['str'], $regs)) {
if (preg_match('(N|X)([0-9])?', $p[$x]['str'], $regs)) {
$p[$x]['seq_type'] = $regs[1];
if ($regs[2] != '')
$p[$x]['seq_pad'] = $regs[2];
@ -389,38 +420,46 @@ function generateProjectNumber($registration_id)
else
$p[$x]['used'] = $p[$x]['x_used'];
} else {
/* FIXME: maybe we should error here? Not having an N
/*
* FIXME: maybe we should error here? Not having an N
* or an X in the projectnumber or projectsort is a bad
* thing */
* thing
*/
$p[$x]['seq_type'] = '';
$p[$x]['seq_pad'] = 0;
$p[$x]['used'] = array();
}
}
/* Find the lowest unused number. FIXME: this could be a config
/*
* Find the lowest unused number. FIXME: this could be a config
* option, we could search for the lowest unused number (if projects
* get deleted), or we could just go +1 beyond the highest */
* get deleted), or we could just go +1 beyond the highest
*/
foreach (array('number', 'sort') as $x) {
if ($p[$x]['seq_type'] == '') continue;
if ($p[$x]['seq_type'] == '')
continue;
$n = 0;
while (1) {
$n++;
if (in_array($n, $p[$x]['used'])) continue;
if (in_array($n, $p[$x]['used']))
continue;
$r = sprintf("%'0{$p[$x]['seq_pad']}d", $n);
$str = preg_replace("{(N|X)([0-9])?}", $r, $p[$x]['str']);
$str = preg_replace('{(N|X)([0-9])?}', $r, $p[$x]['str']);
$p[$x]['str'] = $str;
$p[$x]['n'] = $n;
break;
}
/* If we're using the same number type for sorting, then we, in
/*
* If we're using the same number type for sorting, then we, in
* theory, know what that number is, so we can go ahead and
* blindly use it */
* blindly use it
*/
if ($p['number']['seq_type'] == $p['sort']['seq_type']) {
$r = sprintf("%'0{$p['sort']['seq_pad']}d", $n);
$p['sort']['str'] = preg_replace("{(N|X)([0-9])?}", $r, $p['sort']['str']);
$p['sort']['str'] = preg_replace('{(N|X)([0-9])?}', $r, $p['sort']['str']);
$p['sort']['n'] = $n;
break;
}
@ -443,7 +482,8 @@ function computeRegistrationFee($regid)
$q = $pdo->prepare("SELECT * FROM regfee_items
WHERE year='{$config['FAIRYEAR']}'");
$q->execute();
while ($i = $q->fetch(PDO::FETCH_ASSOC)) $regfee_items[] = $i;
while ($i = $q->fetch(PDO::FETCH_ASSOC))
$regfee_items[] = $i;
$q = $pdo->prepare("SELECT * FROM students WHERE registrations_id='$regid' AND year='" . $config['FAIRYEAR'] . "'");
$q->execute();
@ -451,10 +491,12 @@ function computeRegistrationFee($regid)
$n_tshirts = 0;
$sel = array();
while ($s = $q->fetch(PDO::FETCH_OBJ)) {
if ($s->tshirt != 'none') $n_tshirts++;
if ($s->tshirt != 'none')
$n_tshirts++;
/* Check their regfee items too */
if ($config['participant_regfee_items_enable'] != 'yes') continue;
if ($config['participant_regfee_items_enable'] != 'yes')
continue;
$sel_q = $pdo->prepare("SELECT * FROM regfee_items_link
WHERE students_id={$s->id}");
@ -466,13 +508,13 @@ function computeRegistrationFee($regid)
$regfee = $regfee ?? 0;
if ($config['regfee_per'] == 'student') {
if ($config['regfee'] == ''){
if ($config['regfee'] == '') {
$config['regfee'] = 0;
}
$f = $config['regfee'] * $n_students;
$f = $config['regfee'] * $n_students;
$ret[] = array(
'id' => 'regfee',
'text' => "Fair Registration (per student)",
'text' => 'Fair Registration (per student)',
'base' => $config['regfee'],
'num' => $n_students,
'ext' => $f
@ -481,7 +523,7 @@ function computeRegistrationFee($regid)
} else {
$ret[] = array(
'id' => 'regfee',
'text' => "Fair Registration (per project)",
'text' => 'Fair Registration (per project)',
'base' => $config['regfee'],
'num' => 1,
'ext' => $config['regfee']
@ -497,7 +539,7 @@ function computeRegistrationFee($regid)
if ($n_tshirts != 0) {
$ret[] = array(
'id' => 'tshirt',
'text' => "T-Shirts",
'text' => 'T-Shirts',
'base' => $tsc,
'num' => $n_tshirts,
'ext' => $f
@ -509,9 +551,12 @@ function computeRegistrationFee($regid)
/* $sel will be empty if regfee_items is disabled */
foreach ($regfee_items as $rfi) {
$cnt = 0;
foreach ($sel as $s) if ($rfi['id'] == $s) $cnt++;
foreach ($sel as $s)
if ($rfi['id'] == $s)
$cnt++;
if ($cnt == 0) continue;
if ($cnt == 0)
continue;
$tsc = floatval($rfi['cost']);
@ -533,6 +578,4 @@ function computeRegistrationFee($regid)
return array($regfee, $ret);
}
?>

View File

@ -143,7 +143,9 @@ if (isset($_GET['nummentors'])) {
$numtoshow = $numfound;
// output the current status
$newstatus = mentorStatus();
if ($newstatus != 'complete') {
echo error(i18n('Mentor Information Incomplete'));
} else if ($newstatus == 'complete') {
@ -153,17 +155,19 @@ if ($newstatus != 'complete') {
echo '<form name="nummentorsform" method="get" action="register_participants_mentor.php">';
echo i18n('Number of mentors that helped with the project: ');
echo "<select name=\"nummentors\" onchange=\"document.forms.nummentorsform.submit()\">\n";
if ($registrations_nummentors == null)
if ($registrations_nummentors === -1) {
$sel = 'selected="selected"';
else
} else
$sel = '';
echo "<option $sel value=\"-1\">" . i18n('Choose') . "</option>\n";
for ($x = $config['minmentorsperproject']; $x <= $config['maxmentorsperproject']; $x++) {
// dont let them go less than the number we found. to go less, they must delete each record individually
if ($x < $numfound)
continue;
if ($numtoshow == $x && $registrations_nummentors != null)
if ($numtoshow == $x && $registrations_nummentors !== -1)
$selected = 'selected="selected"';
else
$selected = '';
@ -217,7 +221,7 @@ for ($x = 1; $x <= $numtoshow; $x++) {
echo '<br />';
echo '<br />';
}
if ($numtoshow) {
if ($numtoshow != -1) {
echo '<input type="submit" value="' . i18n('Save Mentor Information') . "\" />\n";
}
echo '</form>';

View File

@ -249,7 +249,7 @@ function user_load($user, $uid = false)
$ts = array();
$ret['types'] = $ts; /* Now we can use in_array('judge', $ret['types']) ; */
/* Convenience */
$ret['name'] = ($ret['firstname'] ? "{$ret['firstname']} " : '') . $ret['lastname'];
@ -402,9 +402,9 @@ function user_save_type_list($u, $db, $fields)
$set .= "`$f`='$data'";
}
if ($set != '') {
$query = "UPDATE $db SET $set WHERE users_id='{$u['id']}'";
$query = "UPDATE $db SET $set WHERE users_id=?";
$stmt = $pdo->prepare($query);
$stmt->execute();
$stmt->execute([$u['id']]);
if ($pdo->errorInfo()) {
show_pdo_errors_if_any($pdo);
}
@ -923,7 +923,7 @@ function user_auth_required($type, $access = '')
if ($auth_type == false) {
message_push(error(i18n('You do not have permission to view that page')));
header("location: {$config['SFIABDIRECTORY']}/user_login.php?type=$type[0]");
exit;
exit;
}
/* Forward to password expired, remember the target URI */

View File

@ -109,10 +109,10 @@ if ($reg_mode == 'invite') {
*/
switch ($action) {
case 'new':
$data_fn = $pdo->quote(stripslashes($_POST['fn']));
$data_ln = $pdo->quote(stripslashes($_POST['ln']));
$data_fn = stripslashes($_POST['fn']);
$data_ln = stripslashes($_POST['ln']);
$data_email = stripslashes($_POST['email']);
$sql_email = $pdo->quote($data_email);
$sql_email = $data_email;
$registrationpassword = $_POST['registrationpassword'];
/* Check the registration singlepassword */

View File

@ -389,7 +389,7 @@ if (in_array('committee', $u['types'])) {
echo '</table>';
}
echo '<input type="submit" onclick="personal_save();return false;" value="' . i18n('Save Personal Information') . "\" />\n";
echo '<input type="submit" onclick="personal_save()" value="' . i18n('Save Personal Information') . "\" />\n";
echo '</form>';
echo '<br />';