From 9842de3e56e7a9de5f65a5351968169704295ce5 Mon Sep 17 00:00:00 2001 From: Ross Parker Date: Tue, 5 Nov 2019 16:53:36 +0800 Subject: [PATCH] v0.6.00 --- Alumni/CHANGEDB.php | 5 ++++ Alumni/CHANGELOG.txt | 4 ++++ Alumni/manifest.php | 2 +- Alumni/publicRegistration.php | 5 ++-- Alumni/publicRegistrationProcess.php | 34 +++++++++++++++++++++++----- Alumni/version.php | 2 +- 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/Alumni/CHANGEDB.php b/Alumni/CHANGEDB.php index 907dc1a..e7f34f1 100644 --- a/Alumni/CHANGEDB.php +++ b/Alumni/CHANGEDB.php @@ -74,3 +74,8 @@ ++$count; $sql[$count][0] = '0.5.00'; $sql[$count][1] = ''; + +//v0.6.00 +++$count; +$sql[$count][0] = '0.6.00'; +$sql[$count][1] = ''; diff --git a/Alumni/CHANGELOG.txt b/Alumni/CHANGELOG.txt index d4b3579..a40e597 100644 --- a/Alumni/CHANGELOG.txt +++ b/Alumni/CHANGELOG.txt @@ -1,5 +1,9 @@ CHANGELOG ========= +v0.6.00 +------- +Email uniqueness check on public registration + v0.5.00 ------- Gibbon Core v17 compatibility diff --git a/Alumni/manifest.php b/Alumni/manifest.php index ec4cd5a..207b0a8 100644 --- a/Alumni/manifest.php +++ b/Alumni/manifest.php @@ -25,7 +25,7 @@ $entryURL = 'alumni_manage.php'; $type = 'Additional'; $category = 'People'; -$version = '0.5.00'; +$version = '0.6.00'; $author = 'Ross Parker'; $url = 'http://rossparker.org/free-learning'; diff --git a/Alumni/publicRegistration.php b/Alumni/publicRegistration.php index ff27ec2..c0fe8bd 100644 --- a/Alumni/publicRegistration.php +++ b/Alumni/publicRegistration.php @@ -44,6 +44,7 @@ $returns = array(); $returns['error5'] = sprintf(__('Your request failed because you do not meet the minimum age for joining this site (%1$s years of age).'), $publicRegistrationMinimumAge); + $returns['error7'] = __('Your request failed because the specified email address has already been registered'); $returns['success0'] = __('Your registration was successfully submitted: a member of our alumni team will be in touch shortly.'); $editLink = ''; if (isset($_GET['editID'])) { @@ -75,7 +76,7 @@ $row = $form->addRow(); $row->addLabel('firstName', __('First Name')); $row->addTextField('firstName')->isRequired()->maxLength(30); - + $row = $form->addRow(); $row->addLabel('surname', __('Surname')); $row->addTextField('surname')->isRequired()->maxLength(30); @@ -95,7 +96,7 @@ $row = $form->addRow(); $row->addLabel('dob', __('Date of Birth')); $row->addDate('dob')->isRequired(); - + $formerRoles = array( 'Student' => __('Student'), 'Staff' => __('Staff'), diff --git a/Alumni/publicRegistrationProcess.php b/Alumni/publicRegistrationProcess.php index 9af1cfc..c80262e 100644 --- a/Alumni/publicRegistrationProcess.php +++ b/Alumni/publicRegistrationProcess.php @@ -79,10 +79,10 @@ $URL .= '&return=error5'; header("Location: {$URL}"); } else { - //Write to database + //Check for uniqueness of username try { - $data = array('title' => $title, 'surname' => $surname, 'firstName' => $firstName, 'officialName' => $officialName, 'maidenName' => $maidenName, 'gender' => $gender, 'username' => $username, 'dob' => $dob, 'email' => $email, 'address1Country' => $address1Country, 'profession' => $profession, 'employer' => $employer, 'jobTitle' => $jobTitle, 'graduatingYear' => $graduatingYear, 'formerRole' => $formerRole); - $sql = 'INSERT INTO alumniAlumnus SET title=:title, surname=:surname, firstName=:firstName, officialName=:officialName, maidenName=:maidenName, gender=:gender, username=:username, dob=:dob, email=:email, address1Country=:address1Country, profession=:profession, employer=:employer, jobTitle=:jobTitle, graduatingYear=:graduatingYear, formerRole=:formerRole'; + $data = array('email' => $email); + $sql = 'SELECT email FROM alumniAlumnus WHERE email=:email'; $result = $connection2->prepare($sql); $result->execute($data); } catch (PDOException $e) { @@ -92,9 +92,31 @@ exit(); } - //Success 0 - $URL .= '&return=success0'; - header("Location: {$URL}"); + if ($result->rowCount() > 0) { + //Fail 7 + $URL .= '&return=error7'; + header("Location: {$URL}"); + exit(); + } + else { + + //Write to database + try { + $data = array('title' => $title, 'surname' => $surname, 'firstName' => $firstName, 'officialName' => $officialName, 'maidenName' => $maidenName, 'gender' => $gender, 'username' => $username, 'dob' => $dob, 'email' => $email, 'address1Country' => $address1Country, 'profession' => $profession, 'employer' => $employer, 'jobTitle' => $jobTitle, 'graduatingYear' => $graduatingYear, 'formerRole' => $formerRole); + $sql = 'INSERT INTO alumniAlumnus SET title=:title, surname=:surname, firstName=:firstName, officialName=:officialName, maidenName=:maidenName, gender=:gender, username=:username, dob=:dob, email=:email, address1Country=:address1Country, profession=:profession, employer=:employer, jobTitle=:jobTitle, graduatingYear=:graduatingYear, formerRole=:formerRole'; + $result = $connection2->prepare($sql); + $result->execute($data); + } catch (PDOException $e) { + //Fail 2 + $URL .= 'return=error2'; + header("Location: {$URL}"); + exit(); + } + + //Success 0 + $URL .= '&return=success0'; + header("Location: {$URL}"); + } } } } diff --git a/Alumni/version.php b/Alumni/version.php index efd263c..ef5878a 100644 --- a/Alumni/version.php +++ b/Alumni/version.php @@ -20,4 +20,4 @@ /** * Sets version information. */ -$moduleVersion = '0.5.00'; +$moduleVersion = '0.6.00';