Compare commits

..

No commits in common. "1385f0049f61c5af8af6de0e5dfc007912e205fa" and "a31417285d63e6e43ea657f8bd1286bb72a6cf56" have entirely different histories.

12 changed files with 194 additions and 275 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -313,12 +313,6 @@ $(document).ready(function() {
$("#editor_tabs").tabs({ $("#editor_tabs").tabs({
create: function(event, ui) {
update_students();
update_project();
update_reg();
},
activate: function( event, ui ) { activate: function( event, ui ) {
update_students(); update_students();
update_project(); 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') { if (get_value_from_array($_GET, 'action') == 'clearaccesscodes') {
$stmt = $pdo->prepare("UPDATE schools SET accesscode='' WHERE year='{$config['FAIRYEAR']}'"); $stmt = $pdo->prepare("UPDATE schools SET accesscode=NULL WHERE year='{$config['FAIRYEAR']}'");
$stmt->execute(); $stmt->execute();
$notice = 'clearaccess'; $notice = 'clearaccess';
} }
@ -237,9 +237,8 @@ if (get_value_from_array($_GET, 'action') == 'edit' || get_value_from_array($_GE
echo '<tr><td>' . i18n('School Language') . '</td><td>'; echo '<tr><td>' . i18n('School Language') . '</td><td>';
echo '<select name="schoollang">'; echo '<select name="schoollang">';
echo '<option value="">' . i18n('Choose') . "</option>\n"; echo '<option value="">' . i18n('Choose') . "</option>\n";
foreach ($config['languages'] AS $k => $l) { foreach ($config['languages'] AS $k => $l) {
echo "<option $sel value=\"$k\">" . i18n($l) . "</option>\n"; echo "<option $sel value=\"$k\">" . i18n($limportant_dates) . "</option>\n";
} }
echo '</select>'; echo '</select>';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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