forked from science-ation/science-ation
Fix registration SQL queries
This commit is contained in:
parent
3a330dcfa7
commit
80c2aecb8e
@ -161,6 +161,7 @@ function projectStatus($reg_id = '')
|
||||
function mentorStatus($reg_id = '')
|
||||
{
|
||||
global $config, $pdo;
|
||||
|
||||
$required_fields = array('firstname', 'lastname', 'phone', 'email', 'organization', 'description');
|
||||
|
||||
if ($reg_id)
|
||||
@ -173,7 +174,8 @@ function mentorStatus($reg_id = '')
|
||||
$q->execute([$rid, $config['FAIRYEAR']]);
|
||||
|
||||
$r = $q->fetch(PDO::FETCH_OBJ);
|
||||
if ($r->nummentors === -1 or $r->nummentors == null) {
|
||||
|
||||
if ($r->nummentors === -1 || $r->nummentors === null) {
|
||||
return 'incomplete';
|
||||
}
|
||||
|
||||
@ -181,7 +183,7 @@ function mentorStatus($reg_id = '')
|
||||
$q->execute([$rid, $config['FAIRYEAR']]);
|
||||
|
||||
// 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, 'minmentorsperproject'))
|
||||
return 'incomplete';
|
||||
|
||||
while ($r = $q->fetch(PDO::FETCH_OBJ)) {
|
||||
@ -326,7 +328,7 @@ function generateProjectNumber($registration_id)
|
||||
|
||||
$reg_id = $registration_id;
|
||||
|
||||
$q = $pdo->prepare("SELECT projects.projectcategories_id,
|
||||
$q = $pdo->prepare('SELECT projects.projectcategories_id,
|
||||
projects.projectdivisions_id,
|
||||
projectcategories.category_shortform,
|
||||
projectdivisions.division_shortform
|
||||
@ -340,7 +342,7 @@ function generateProjectNumber($registration_id)
|
||||
AND projects.projectcategories_id=projectcategories.id
|
||||
AND projectcategories.year=?
|
||||
AND projectdivisions.year=?
|
||||
");
|
||||
');
|
||||
$q->execute([$reg_id, $config['FAIRYEAR'], $config['FAIRYEAR']]);
|
||||
show_pdo_errors_if_any($pdo);
|
||||
$r = $q->fetch(PDO::FETCH_OBJ);
|
||||
@ -359,11 +361,10 @@ function generateProjectNumber($registration_id)
|
||||
* 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't have to do anything fancy with,
|
||||
* and setup some variables for future queries
|
||||
@ -377,7 +378,6 @@ 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
|
||||
@ -463,7 +463,6 @@ function generateProjectNumber($registration_id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
$p['number']['str'],
|
||||
$p['sort']['str'],
|
||||
|
@ -143,6 +143,7 @@ while ($sr = $sq->fetch(PDO::FETCH_OBJ)) {
|
||||
$stmt->execute([
|
||||
$_SESSION['registration_id'],
|
||||
$sr->id,
|
||||
$config['FAIRYEAR']
|
||||
]);
|
||||
$id = $pdo->lastInsertId();
|
||||
unset($r);
|
||||
|
@ -72,37 +72,33 @@ if (get_value_from_array($_POST, 'action') == 'save') {
|
||||
// only insert if we have a name
|
||||
if ($_POST['lastname'][$x]) {
|
||||
// INSERT new record
|
||||
$stmt = $pdo->prepare('INSERT INTO mentors (registrations_id,firstname,lastname,email,phone,organization,position,description,year) VALUES (
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?)');
|
||||
$stmt->execute([$_SESSION['registration_id'],stripslashes($_POST['firstname'][$x]),stripslashes($_POST['lastname'][$x]),
|
||||
stripslashes($_POST['email'][$x]),stripslashes($_POST['phone'][$x]),stripslashes($_POST['organization'][$x]),stripslashes($_POST['position'][$x]),
|
||||
stripslashes($_POST['description'][$x]),$config['FAIRYEAR']]);
|
||||
$stmt = $pdo->prepare('INSERT INTO mentors (registrations_id,firstname,lastname,email,phone,organization,position,description,year) VALUES ('
|
||||
. "'" . $_SESSION['registration_id'] . "', "
|
||||
. "'" . stripslashes($_POST['firstname'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['lastname'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['email'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['phone'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['organization'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['position'][$x]) . "', "
|
||||
. "'" . stripslashes($_POST['description'][$x]) . "', "
|
||||
. "'" . $config['FAIRYEAR'] . "')");
|
||||
$stmt->execute();
|
||||
show_pdo_errors_if_any($pdo);
|
||||
|
||||
echo notice(i18n('%1 %2 successfully added', array($_POST['firstname'][$x], $_POST['lastname'][$x])));
|
||||
}
|
||||
} else {
|
||||
// UPDATE existing record
|
||||
$stmt = $pdo->prepare('UPDATE mentors SET
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
?,
|
||||
. "organization=?,"
|
||||
. "position=?",
|
||||
. "description=?"
|
||||
. "WHERE id=?"');
|
||||
$stmt->execute([stripslashes($_POST['firstname'][$x]),stripslashes($_POST['lastname'][$x]),stripslashes($_POST['email'][$x]),
|
||||
stripslashes($_POST['phone'][$x]),stripslashes($_POST['organization'][$x]),stripslashes($_POST['position'][$x]),
|
||||
stripslashes($_POST['description'][$x]),$_POST['id'][$x]]);
|
||||
$stmt = $pdo->prepare('UPDATE mentors SET '
|
||||
. "firstname='" . stripslashes($_POST['firstname'][$x]) . "', "
|
||||
. "lastname='" . stripslashes($_POST['lastname'][$x]) . "', "
|
||||
. "email='" . stripslashes($_POST['email'][$x]) . "', "
|
||||
. "phone='" . stripslashes($_POST['phone'][$x]) . "', "
|
||||
. "organization='" . stripslashes($_POST['organization'][$x]) . "', "
|
||||
. "position='" . stripslashes($_POST['position'][$x]) . "', "
|
||||
. "description='" . stripslashes($_POST['description'][$x]) . "' "
|
||||
. "WHERE id='" . $_POST['id'][$x] . "'");
|
||||
$stmt->execute();
|
||||
echo notice(i18n('%1 %2 successfully updated', array($_POST['firstname'][$x], $_POST['lastname'][$x])));
|
||||
}
|
||||
$x++;
|
||||
@ -147,7 +143,6 @@ if (isset($_GET['nummentors'])) {
|
||||
$numtoshow = $numfound;
|
||||
|
||||
// output the current status
|
||||
|
||||
$newstatus = mentorStatus();
|
||||
|
||||
if ($newstatus != 'complete') {
|
||||
|
@ -61,7 +61,7 @@ $authinfo = $q->fetch(PDO::FETCH_OBJ);
|
||||
<meta charset="utf-8" />
|
||||
<title><?= i18n('Division Selector') ?></title>
|
||||
<link rel="stylesheet" href="<?= $config['SFIABDIRECTORY'] ?>/sfiab.css" type="text/css" />
|
||||
</head>testi-bg.jpg
|
||||
</head>
|
||||
<body>
|
||||
<?
|
||||
echo '<div id="emptypopup">';
|
||||
|
Loading…
x
Reference in New Issue
Block a user